1 | The following changes since commit a11f65ec1b8adcb012b89c92819cbda4dc25aaf1: | 1 | The following changes since commit a5ba0a7e4e150d1350a041f0d0ef9ca6c8d7c307: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2022-11-01 13:49:33 -0400) | 3 | Merge tag 'pull-aspeed-20241211' of https://github.com/legoater/qemu into staging (2024-12-11 15:16:47 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://gitlab.com/gaosong/qemu.git tags/pull-loongarch-20221103 | 7 | https://gitlab.com/bibo-mao/qemu.git pull-loongarch-20241213 |
8 | 8 | ||
9 | for you to fetch changes up to d31e2b1af7e6db41e6088679babc3893bd69b4b3: | 9 | for you to fetch changes up to 78aa256571aa06f32001bd80635a1858187c609b: |
10 | 10 | ||
11 | target/loongarch: Fix raise_mmu_exception() set wrong exception_index (2022-11-03 17:59:19 +0800) | 11 | hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic (2024-12-13 14:39:39 +0800) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | pull-loongarch-20221103 | 14 | pull-loongarch-20241213 |
15 | 15 | ||
16 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
17 | Song Gao (2): | 17 | Bibo Mao (8): |
18 | target/loongarch: Add exception subcode | 18 | include: Add loongarch_pic_common header file |
19 | target/loongarch: Fix raise_mmu_exception() set wrong exception_index | 19 | include: Move struct LoongArchPCHPIC to loongarch_pic_common header file |
20 | hw/intc/loongarch_pch: Merge instance_init() into realize() | ||
21 | hw/intc/loongarch_pch: Rename LoongArchPCHPIC with LoongArchPICCommonState | ||
22 | hw/intc/loongarch_pch: Move some functions to file loongarch_pic_common | ||
23 | hw/intc/loongarch_pch: Inherit from loongarch_pic_common | ||
24 | hw/intc/loongarch_pch: Add pre_save and post_load interfaces | ||
25 | hw/intc/loongarch_pch: Code cleanup about loongarch_pch_pic | ||
20 | 26 | ||
21 | Xiaojuan Yang (5): | 27 | hw/intc/loongarch_pch_pic.c | 106 +++++++++++---------------------- |
22 | hw/intc: Convert the memops to with_attrs in LoongArch extioi | 28 | hw/intc/loongarch_pic_common.c | 97 ++++++++++++++++++++++++++++++ |
23 | hw/intc: Fix LoongArch extioi coreisr accessing | 29 | hw/intc/meson.build | 2 +- |
24 | hw/loongarch: Load FDT table into dram memory space | 30 | hw/loongarch/virt.c | 2 +- |
25 | hw/loongarch: Improve fdt for LoongArch virt machine | 31 | include/hw/intc/loongarch_pch_pic.h | 70 +++++----------------- |
26 | hw/loongarch: Add TPM device for LoongArch virt machine | 32 | include/hw/intc/loongarch_pic_common.h | 82 +++++++++++++++++++++++++ |
27 | 33 | 6 files changed, 230 insertions(+), 129 deletions(-) | |
28 | hw/intc/loongarch_extioi.c | 41 ++++++++++++++++------------- | 34 | create mode 100644 hw/intc/loongarch_pic_common.c |
29 | hw/intc/trace-events | 3 +-- | 35 | create mode 100644 include/hw/intc/loongarch_pic_common.h |
30 | hw/loongarch/acpi-build.c | 50 +++++++++++++++++++++++++++++++++-- | ||
31 | hw/loongarch/virt.c | 53 ++++++++++++++++++++++++++++++++----- | ||
32 | include/hw/loongarch/virt.h | 3 --- | ||
33 | include/hw/pci-host/ls7a.h | 1 + | ||
34 | target/loongarch/cpu.c | 8 ++++-- | ||
35 | target/loongarch/cpu.h | 58 ++++++++++++++++++++++------------------- | ||
36 | target/loongarch/iocsr_helper.c | 19 ++++++++------ | ||
37 | target/loongarch/tlb_helper.c | 5 ++-- | ||
38 | 10 files changed, 170 insertions(+), 71 deletions(-) | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Add common header file hw/intc/loongarch_pic_common.h, and move | ||
2 | some macro definition from hw/intc/loongarch_pch_pic.h to the common | ||
3 | header file. | ||
1 | 4 | ||
5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> | ||
6 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
7 | --- | ||
8 | include/hw/intc/loongarch_pch_pic.h | 36 +++------------------- | ||
9 | include/hw/intc/loongarch_pic_common.h | 42 ++++++++++++++++++++++++++ | ||
10 | 2 files changed, 47 insertions(+), 31 deletions(-) | ||
11 | create mode 100644 include/hw/intc/loongarch_pic_common.h | ||
12 | |||
13 | diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/intc/loongarch_pch_pic.h | ||
16 | +++ b/include/hw/intc/loongarch_pch_pic.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | * Copyright (c) 2021 Loongson Technology Corporation Limited | ||
19 | */ | ||
20 | |||
21 | -#include "hw/sysbus.h" | ||
22 | +#ifndef HW_LOONGARCH_PCH_PIC_H | ||
23 | +#define HW_LOONGARCH_PCH_PIC_H | ||
24 | + | ||
25 | +#include "hw/intc/loongarch_pic_common.h" | ||
26 | |||
27 | #define TYPE_LOONGARCH_PCH_PIC "loongarch_pch_pic" | ||
28 | #define PCH_PIC_NAME(name) TYPE_LOONGARCH_PCH_PIC#name | ||
29 | OBJECT_DECLARE_SIMPLE_TYPE(LoongArchPCHPIC, LOONGARCH_PCH_PIC) | ||
30 | |||
31 | -#define PCH_PIC_INT_ID_VAL 0x7000000UL | ||
32 | -#define PCH_PIC_INT_ID_VER 0x1UL | ||
33 | - | ||
34 | -#define PCH_PIC_INT_ID_LO 0x00 | ||
35 | -#define PCH_PIC_INT_ID_HI 0x04 | ||
36 | -#define PCH_PIC_INT_MASK_LO 0x20 | ||
37 | -#define PCH_PIC_INT_MASK_HI 0x24 | ||
38 | -#define PCH_PIC_HTMSI_EN_LO 0x40 | ||
39 | -#define PCH_PIC_HTMSI_EN_HI 0x44 | ||
40 | -#define PCH_PIC_INT_EDGE_LO 0x60 | ||
41 | -#define PCH_PIC_INT_EDGE_HI 0x64 | ||
42 | -#define PCH_PIC_INT_CLEAR_LO 0x80 | ||
43 | -#define PCH_PIC_INT_CLEAR_HI 0x84 | ||
44 | -#define PCH_PIC_AUTO_CTRL0_LO 0xc0 | ||
45 | -#define PCH_PIC_AUTO_CTRL0_HI 0xc4 | ||
46 | -#define PCH_PIC_AUTO_CTRL1_LO 0xe0 | ||
47 | -#define PCH_PIC_AUTO_CTRL1_HI 0xe4 | ||
48 | -#define PCH_PIC_ROUTE_ENTRY_OFFSET 0x100 | ||
49 | -#define PCH_PIC_ROUTE_ENTRY_END 0x13f | ||
50 | -#define PCH_PIC_HTMSI_VEC_OFFSET 0x200 | ||
51 | -#define PCH_PIC_HTMSI_VEC_END 0x23f | ||
52 | -#define PCH_PIC_INT_STATUS_LO 0x3a0 | ||
53 | -#define PCH_PIC_INT_STATUS_HI 0x3a4 | ||
54 | -#define PCH_PIC_INT_POL_LO 0x3e0 | ||
55 | -#define PCH_PIC_INT_POL_HI 0x3e4 | ||
56 | - | ||
57 | -#define STATUS_LO_START 0 | ||
58 | -#define STATUS_HI_START 0x4 | ||
59 | -#define POL_LO_START 0x40 | ||
60 | -#define POL_HI_START 0x44 | ||
61 | struct LoongArchPCHPIC { | ||
62 | SysBusDevice parent_obj; | ||
63 | qemu_irq parent_irq[64]; | ||
64 | @@ -XXX,XX +XXX,XX @@ struct LoongArchPCHPIC { | ||
65 | MemoryRegion iomem8; | ||
66 | unsigned int irq_num; | ||
67 | }; | ||
68 | +#endif /* HW_LOONGARCH_PCH_PIC_H */ | ||
69 | diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h | ||
70 | new file mode 100644 | ||
71 | index XXXXXXX..XXXXXXX | ||
72 | --- /dev/null | ||
73 | +++ b/include/hw/intc/loongarch_pic_common.h | ||
74 | @@ -XXX,XX +XXX,XX @@ | ||
75 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
76 | +/* | ||
77 | + * LoongArch 7A1000 I/O interrupt controller definitions | ||
78 | + * Copyright (c) 2024 Loongson Technology Corporation Limited | ||
79 | + */ | ||
80 | + | ||
81 | +#ifndef HW_LOONGARCH_PIC_COMMON_H | ||
82 | +#define HW_LOONGARCH_PIC_COMMON_H | ||
83 | + | ||
84 | +#include "hw/pci-host/ls7a.h" | ||
85 | +#include "hw/sysbus.h" | ||
86 | + | ||
87 | +#define PCH_PIC_INT_ID_VAL 0x7000000UL | ||
88 | +#define PCH_PIC_INT_ID_VER 0x1UL | ||
89 | +#define PCH_PIC_INT_ID_LO 0x00 | ||
90 | +#define PCH_PIC_INT_ID_HI 0x04 | ||
91 | +#define PCH_PIC_INT_MASK_LO 0x20 | ||
92 | +#define PCH_PIC_INT_MASK_HI 0x24 | ||
93 | +#define PCH_PIC_HTMSI_EN_LO 0x40 | ||
94 | +#define PCH_PIC_HTMSI_EN_HI 0x44 | ||
95 | +#define PCH_PIC_INT_EDGE_LO 0x60 | ||
96 | +#define PCH_PIC_INT_EDGE_HI 0x64 | ||
97 | +#define PCH_PIC_INT_CLEAR_LO 0x80 | ||
98 | +#define PCH_PIC_INT_CLEAR_HI 0x84 | ||
99 | +#define PCH_PIC_AUTO_CTRL0_LO 0xc0 | ||
100 | +#define PCH_PIC_AUTO_CTRL0_HI 0xc4 | ||
101 | +#define PCH_PIC_AUTO_CTRL1_LO 0xe0 | ||
102 | +#define PCH_PIC_AUTO_CTRL1_HI 0xe4 | ||
103 | +#define PCH_PIC_ROUTE_ENTRY_OFFSET 0x100 | ||
104 | +#define PCH_PIC_ROUTE_ENTRY_END 0x13f | ||
105 | +#define PCH_PIC_HTMSI_VEC_OFFSET 0x200 | ||
106 | +#define PCH_PIC_HTMSI_VEC_END 0x23f | ||
107 | +#define PCH_PIC_INT_STATUS_LO 0x3a0 | ||
108 | +#define PCH_PIC_INT_STATUS_HI 0x3a4 | ||
109 | +#define PCH_PIC_INT_POL_LO 0x3e0 | ||
110 | +#define PCH_PIC_INT_POL_HI 0x3e4 | ||
111 | + | ||
112 | +#define STATUS_LO_START 0 | ||
113 | +#define STATUS_HI_START 0x4 | ||
114 | +#define POL_LO_START 0x40 | ||
115 | +#define POL_HI_START 0x44 | ||
116 | +#endif /* HW_LOONGARCH_PIC_COMMON_H */ | ||
117 | -- | ||
118 | 2.43.5 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Move structure LoongArchPCHPIC from header file loongarch_pch_pic.h | ||
2 | to file loongarch_pic_common.h, and rename structure name with | ||
3 | LoongArchPICCommonState. | ||
1 | 4 | ||
5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> | ||
6 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
7 | --- | ||
8 | include/hw/intc/loongarch_pch_pic.h | 27 +------------------------ | ||
9 | include/hw/intc/loongarch_pic_common.h | 28 ++++++++++++++++++++++++++ | ||
10 | 2 files changed, 29 insertions(+), 26 deletions(-) | ||
11 | |||
12 | diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/intc/loongarch_pch_pic.h | ||
15 | +++ b/include/hw/intc/loongarch_pch_pic.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | |||
18 | #include "hw/intc/loongarch_pic_common.h" | ||
19 | |||
20 | +#define LoongArchPCHPIC LoongArchPICCommonState | ||
21 | #define TYPE_LOONGARCH_PCH_PIC "loongarch_pch_pic" | ||
22 | #define PCH_PIC_NAME(name) TYPE_LOONGARCH_PCH_PIC#name | ||
23 | OBJECT_DECLARE_SIMPLE_TYPE(LoongArchPCHPIC, LOONGARCH_PCH_PIC) | ||
24 | |||
25 | -struct LoongArchPCHPIC { | ||
26 | - SysBusDevice parent_obj; | ||
27 | - qemu_irq parent_irq[64]; | ||
28 | - uint64_t int_mask; /*0x020 interrupt mask register*/ | ||
29 | - uint64_t htmsi_en; /*0x040 1=msi*/ | ||
30 | - uint64_t intedge; /*0x060 edge=1 level =0*/ | ||
31 | - uint64_t intclr; /*0x080 for clean edge int,set 1 clean,set 0 is noused*/ | ||
32 | - uint64_t auto_crtl0; /*0x0c0*/ | ||
33 | - uint64_t auto_crtl1; /*0x0e0*/ | ||
34 | - uint64_t last_intirr; /* edge detection */ | ||
35 | - uint64_t intirr; /* 0x380 interrupt request register */ | ||
36 | - uint64_t intisr; /* 0x3a0 interrupt service register */ | ||
37 | - /* | ||
38 | - * 0x3e0 interrupt level polarity selection | ||
39 | - * register 0 for high level trigger | ||
40 | - */ | ||
41 | - uint64_t int_polarity; | ||
42 | - | ||
43 | - uint8_t route_entry[64]; /*0x100 - 0x138*/ | ||
44 | - uint8_t htmsi_vector[64]; /*0x200 - 0x238*/ | ||
45 | - | ||
46 | - MemoryRegion iomem32_low; | ||
47 | - MemoryRegion iomem32_high; | ||
48 | - MemoryRegion iomem8; | ||
49 | - unsigned int irq_num; | ||
50 | -}; | ||
51 | #endif /* HW_LOONGARCH_PCH_PIC_H */ | ||
52 | diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/include/hw/intc/loongarch_pic_common.h | ||
55 | +++ b/include/hw/intc/loongarch_pic_common.h | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #define STATUS_HI_START 0x4 | ||
58 | #define POL_LO_START 0x40 | ||
59 | #define POL_HI_START 0x44 | ||
60 | + | ||
61 | +struct LoongArchPICCommonState { | ||
62 | + SysBusDevice parent_obj; | ||
63 | + | ||
64 | + qemu_irq parent_irq[64]; | ||
65 | + uint64_t int_mask; /* 0x020 interrupt mask register */ | ||
66 | + uint64_t htmsi_en; /* 0x040 1=msi */ | ||
67 | + uint64_t intedge; /* 0x060 edge=1 level=0 */ | ||
68 | + uint64_t intclr; /* 0x080 clean edge int, set 1 clean, 0 noused */ | ||
69 | + uint64_t auto_crtl0; /* 0x0c0 */ | ||
70 | + uint64_t auto_crtl1; /* 0x0e0 */ | ||
71 | + uint64_t last_intirr; /* edge detection */ | ||
72 | + uint64_t intirr; /* 0x380 interrupt request register */ | ||
73 | + uint64_t intisr; /* 0x3a0 interrupt service register */ | ||
74 | + /* | ||
75 | + * 0x3e0 interrupt level polarity selection | ||
76 | + * register 0 for high level trigger | ||
77 | + */ | ||
78 | + uint64_t int_polarity; | ||
79 | + | ||
80 | + uint8_t route_entry[64]; /* 0x100 - 0x138 */ | ||
81 | + uint8_t htmsi_vector[64]; /* 0x200 - 0x238 */ | ||
82 | + | ||
83 | + MemoryRegion iomem32_low; | ||
84 | + MemoryRegion iomem32_high; | ||
85 | + MemoryRegion iomem8; | ||
86 | + unsigned int irq_num; | ||
87 | +}; | ||
88 | #endif /* HW_LOONGARCH_PIC_COMMON_H */ | ||
89 | -- | ||
90 | 2.43.5 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Memory region is created in instance_init(), merge it into function | ||
2 | realize(). There is no special class_init() for loongarch_pch object. | ||
1 | 3 | ||
4 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> | ||
5 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
6 | --- | ||
7 | hw/intc/loongarch_pch_pic.c | 15 ++++----------- | ||
8 | 1 file changed, 4 insertions(+), 11 deletions(-) | ||
9 | |||
10 | diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/hw/intc/loongarch_pch_pic.c | ||
13 | +++ b/hw/intc/loongarch_pch_pic.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_reset(DeviceState *d) | ||
15 | static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) | ||
16 | { | ||
17 | LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev); | ||
18 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
19 | |||
20 | if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) { | ||
21 | error_setg(errp, "Invalid 'pic_irq_num'"); | ||
22 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) | ||
23 | |||
24 | qdev_init_gpio_out(dev, s->parent_irq, s->irq_num); | ||
25 | qdev_init_gpio_in(dev, pch_pic_irq_handler, s->irq_num); | ||
26 | -} | ||
27 | - | ||
28 | -static void loongarch_pch_pic_init(Object *obj) | ||
29 | -{ | ||
30 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(obj); | ||
31 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
32 | - | ||
33 | - memory_region_init_io(&s->iomem32_low, obj, | ||
34 | + memory_region_init_io(&s->iomem32_low, OBJECT(dev), | ||
35 | &loongarch_pch_pic_reg32_low_ops, | ||
36 | s, PCH_PIC_NAME(.reg32_part1), 0x100); | ||
37 | - memory_region_init_io(&s->iomem8, obj, &loongarch_pch_pic_reg8_ops, | ||
38 | + memory_region_init_io(&s->iomem8, OBJECT(dev), &loongarch_pch_pic_reg8_ops, | ||
39 | s, PCH_PIC_NAME(.reg8), 0x2a0); | ||
40 | - memory_region_init_io(&s->iomem32_high, obj, | ||
41 | + memory_region_init_io(&s->iomem32_high, OBJECT(dev), | ||
42 | &loongarch_pch_pic_reg32_high_ops, | ||
43 | s, PCH_PIC_NAME(.reg32_part2), 0xc60); | ||
44 | sysbus_init_mmio(sbd, &s->iomem32_low); | ||
45 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo loongarch_pch_pic_info = { | ||
46 | .name = TYPE_LOONGARCH_PCH_PIC, | ||
47 | .parent = TYPE_SYS_BUS_DEVICE, | ||
48 | .instance_size = sizeof(LoongArchPCHPIC), | ||
49 | - .instance_init = loongarch_pch_pic_init, | ||
50 | .class_init = loongarch_pch_pic_class_init, | ||
51 | }; | ||
52 | |||
53 | -- | ||
54 | 2.43.5 | diff view generated by jsdifflib |
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 1 | With pic vmstate, rename structure name vmstate_loongarch_pch_pic with |
---|---|---|---|
2 | vmstate_loongarch_pic_common, and with pic property rename | ||
3 | loongarch_pch_pic_properties with loongarch_pic_common_properties. | ||
2 | 4 | ||
3 | Converting the MemoryRegionOps read/write handlers to | 5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
4 | with_attrs in LoongArch extioi emulation. | 6 | Reviewed-by: Song Gao <gaosong@loongson.cn> |
7 | --- | ||
8 | hw/intc/loongarch_pch_pic.c | 52 +++++++++++++++++++++++-------------- | ||
9 | 1 file changed, 32 insertions(+), 20 deletions(-) | ||
5 | 10 | ||
6 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 11 | diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-Id: <20221021015307.2570844-2-yangxiaojuan@loongson.cn> | ||
10 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
11 | --- | ||
12 | hw/intc/loongarch_extioi.c | 31 +++++++++++++++++-------------- | ||
13 | hw/intc/trace-events | 3 +-- | ||
14 | 2 files changed, 18 insertions(+), 16 deletions(-) | ||
15 | |||
16 | diff --git a/hw/intc/loongarch_extioi.c b/hw/intc/loongarch_extioi.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/loongarch_extioi.c | 13 | --- a/hw/intc/loongarch_pch_pic.c |
19 | +++ b/hw/intc/loongarch_extioi.c | 14 | +++ b/hw/intc/loongarch_pch_pic.c |
20 | @@ -XXX,XX +XXX,XX @@ static void extioi_setirq(void *opaque, int irq, int level) | 15 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_reset(DeviceState *d) |
21 | extioi_update_irq(s, irq, level); | 16 | s->int_polarity = 0x0; |
22 | } | 17 | } |
23 | 18 | ||
24 | -static uint64_t extioi_readw(void *opaque, hwaddr addr, unsigned size) | 19 | +static void loongarch_pic_common_realize(DeviceState *dev, Error **errp) |
25 | +static MemTxResult extioi_readw(void *opaque, hwaddr addr, uint64_t *data, | 20 | +{ |
26 | + unsigned size, MemTxAttrs attrs) | 21 | + LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev); |
22 | + | ||
23 | + if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) { | ||
24 | + error_setg(errp, "Invalid 'pic_irq_num'"); | ||
25 | + return; | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) | ||
27 | { | 30 | { |
28 | LoongArchExtIOI *s = LOONGARCH_EXTIOI(opaque); | 31 | LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev); |
29 | unsigned long offset = addr & 0xffff; | 32 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
30 | - uint32_t index, cpu, ret = 0; | 33 | + Error *local_err = NULL; |
31 | + uint32_t index, cpu; | 34 | |
32 | 35 | - if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) { | |
33 | switch (offset) { | 36 | - error_setg(errp, "Invalid 'pic_irq_num'"); |
34 | case EXTIOI_NODETYPE_START ... EXTIOI_NODETYPE_END - 1: | 37 | + loongarch_pic_common_realize(dev, &local_err); |
35 | index = (offset - EXTIOI_NODETYPE_START) >> 2; | 38 | + if (local_err) { |
36 | - ret = s->nodetype[index]; | 39 | + error_propagate(errp, local_err); |
37 | + *data = s->nodetype[index]; | 40 | return; |
38 | break; | ||
39 | case EXTIOI_IPMAP_START ... EXTIOI_IPMAP_END - 1: | ||
40 | index = (offset - EXTIOI_IPMAP_START) >> 2; | ||
41 | - ret = s->ipmap[index]; | ||
42 | + *data = s->ipmap[index]; | ||
43 | break; | ||
44 | case EXTIOI_ENABLE_START ... EXTIOI_ENABLE_END - 1: | ||
45 | index = (offset - EXTIOI_ENABLE_START) >> 2; | ||
46 | - ret = s->enable[index]; | ||
47 | + *data = s->enable[index]; | ||
48 | break; | ||
49 | case EXTIOI_BOUNCE_START ... EXTIOI_BOUNCE_END - 1: | ||
50 | index = (offset - EXTIOI_BOUNCE_START) >> 2; | ||
51 | - ret = s->bounce[index]; | ||
52 | + *data = s->bounce[index]; | ||
53 | break; | ||
54 | case EXTIOI_COREISR_START ... EXTIOI_COREISR_END - 1: | ||
55 | index = ((offset - EXTIOI_COREISR_START) & 0x1f) >> 2; | ||
56 | cpu = ((offset - EXTIOI_COREISR_START) >> 8) & 0x3; | ||
57 | - ret = s->coreisr[cpu][index]; | ||
58 | + *data = s->coreisr[cpu][index]; | ||
59 | break; | ||
60 | case EXTIOI_COREMAP_START ... EXTIOI_COREMAP_END - 1: | ||
61 | index = (offset - EXTIOI_COREMAP_START) >> 2; | ||
62 | - ret = s->coremap[index]; | ||
63 | + *data = s->coremap[index]; | ||
64 | break; | ||
65 | default: | ||
66 | break; | ||
67 | } | 41 | } |
68 | 42 | ||
69 | - trace_loongarch_extioi_readw(addr, ret); | 43 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) |
70 | - return ret; | 44 | |
71 | + trace_loongarch_extioi_readw(addr, *data); | ||
72 | + return MEMTX_OK; | ||
73 | } | 45 | } |
74 | 46 | ||
75 | static inline void extioi_enable_irq(LoongArchExtIOI *s, int index,\ | 47 | -static Property loongarch_pch_pic_properties[] = { |
76 | @@ -XXX,XX +XXX,XX @@ static inline void extioi_enable_irq(LoongArchExtIOI *s, int index,\ | 48 | - DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPCHPIC, irq_num, 0), |
49 | +static Property loongarch_pic_common_properties[] = { | ||
50 | + DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0), | ||
51 | DEFINE_PROP_END_OF_LIST(), | ||
52 | }; | ||
53 | |||
54 | -static const VMStateDescription vmstate_loongarch_pch_pic = { | ||
55 | - .name = TYPE_LOONGARCH_PCH_PIC, | ||
56 | +static const VMStateDescription vmstate_loongarch_pic_common = { | ||
57 | + .name = "loongarch_pch_pic", | ||
58 | .version_id = 1, | ||
59 | .minimum_version_id = 1, | ||
60 | .fields = (const VMStateField[]) { | ||
61 | - VMSTATE_UINT64(int_mask, LoongArchPCHPIC), | ||
62 | - VMSTATE_UINT64(htmsi_en, LoongArchPCHPIC), | ||
63 | - VMSTATE_UINT64(intedge, LoongArchPCHPIC), | ||
64 | - VMSTATE_UINT64(intclr, LoongArchPCHPIC), | ||
65 | - VMSTATE_UINT64(auto_crtl0, LoongArchPCHPIC), | ||
66 | - VMSTATE_UINT64(auto_crtl1, LoongArchPCHPIC), | ||
67 | - VMSTATE_UINT8_ARRAY(route_entry, LoongArchPCHPIC, 64), | ||
68 | - VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPCHPIC, 64), | ||
69 | - VMSTATE_UINT64(last_intirr, LoongArchPCHPIC), | ||
70 | - VMSTATE_UINT64(intirr, LoongArchPCHPIC), | ||
71 | - VMSTATE_UINT64(intisr, LoongArchPCHPIC), | ||
72 | - VMSTATE_UINT64(int_polarity, LoongArchPCHPIC), | ||
73 | + VMSTATE_UINT64(int_mask, LoongArchPICCommonState), | ||
74 | + VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState), | ||
75 | + VMSTATE_UINT64(intedge, LoongArchPICCommonState), | ||
76 | + VMSTATE_UINT64(intclr, LoongArchPICCommonState), | ||
77 | + VMSTATE_UINT64(auto_crtl0, LoongArchPICCommonState), | ||
78 | + VMSTATE_UINT64(auto_crtl1, LoongArchPICCommonState), | ||
79 | + VMSTATE_UINT8_ARRAY(route_entry, LoongArchPICCommonState, 64), | ||
80 | + VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPICCommonState, 64), | ||
81 | + VMSTATE_UINT64(last_intirr, LoongArchPICCommonState), | ||
82 | + VMSTATE_UINT64(intirr, LoongArchPICCommonState), | ||
83 | + VMSTATE_UINT64(intisr, LoongArchPICCommonState), | ||
84 | + VMSTATE_UINT64(int_polarity, LoongArchPICCommonState), | ||
85 | VMSTATE_END_OF_LIST() | ||
77 | } | 86 | } |
87 | }; | ||
88 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data) | ||
89 | |||
90 | dc->realize = loongarch_pch_pic_realize; | ||
91 | device_class_set_legacy_reset(dc, loongarch_pch_pic_reset); | ||
92 | - dc->vmsd = &vmstate_loongarch_pch_pic; | ||
93 | - device_class_set_props(dc, loongarch_pch_pic_properties); | ||
94 | + dc->vmsd = &vmstate_loongarch_pic_common; | ||
95 | + device_class_set_props(dc, loongarch_pic_common_properties); | ||
78 | } | 96 | } |
79 | 97 | ||
80 | -static void extioi_writew(void *opaque, hwaddr addr, | 98 | static const TypeInfo loongarch_pch_pic_info = { |
81 | - uint64_t val, unsigned size) | ||
82 | +static MemTxResult extioi_writew(void *opaque, hwaddr addr, | ||
83 | + uint64_t val, unsigned size, | ||
84 | + MemTxAttrs attrs) | ||
85 | { | ||
86 | LoongArchExtIOI *s = LOONGARCH_EXTIOI(opaque); | ||
87 | int i, cpu, index, old_data, irq; | ||
88 | @@ -XXX,XX +XXX,XX @@ static void extioi_writew(void *opaque, hwaddr addr, | ||
89 | default: | ||
90 | break; | ||
91 | } | ||
92 | + return MEMTX_OK; | ||
93 | } | ||
94 | |||
95 | static const MemoryRegionOps extioi_ops = { | ||
96 | - .read = extioi_readw, | ||
97 | - .write = extioi_writew, | ||
98 | + .read_with_attrs = extioi_readw, | ||
99 | + .write_with_attrs = extioi_writew, | ||
100 | .impl.min_access_size = 4, | ||
101 | .impl.max_access_size = 4, | ||
102 | .valid.min_access_size = 4, | ||
103 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/hw/intc/trace-events | ||
106 | +++ b/hw/intc/trace-events | ||
107 | @@ -XXX,XX +XXX,XX @@ loongarch_msi_set_irq(int irq_num) "set msi irq %d" | ||
108 | |||
109 | # loongarch_extioi.c | ||
110 | loongarch_extioi_setirq(int irq, int level) "set extirq irq %d level %d" | ||
111 | -loongarch_extioi_readw(uint64_t addr, uint32_t val) "addr: 0x%"PRIx64 "val: 0x%x" | ||
112 | +loongarch_extioi_readw(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64 "val: 0x%" PRIx64 | ||
113 | loongarch_extioi_writew(uint64_t addr, uint64_t val) "addr: 0x%"PRIx64 "val: 0x%" PRIx64 | ||
114 | - | ||
115 | -- | 99 | -- |
116 | 2.31.1 | 100 | 2.43.5 |
117 | |||
118 | diff view generated by jsdifflib |
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 1 | Move some common functions to file loongarch_pic_common.c, the common |
---|---|---|---|
2 | functions include loongarch_pic_common_realize(), property structure | ||
3 | loongarch_pic_common_properties and vmstate structure | ||
4 | vmstate_loongarch_pic_common. | ||
2 | 5 | ||
3 | Load FDT table into dram memory space, and the addr is 2 MiB. | 6 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
4 | Since lowmem region starts from 0, FDT base address is located | 7 | Reviewed-by: Song Gao <gaosong@loongson.cn> |
5 | at 2 MiB to avoid NULL pointer access. | 8 | --- |
9 | hw/intc/loongarch_pch_pic.c | 37 +----------------------------- | ||
10 | hw/intc/loongarch_pic_common.c | 41 ++++++++++++++++++++++++++++++++++ | ||
11 | 2 files changed, 42 insertions(+), 36 deletions(-) | ||
12 | create mode 100644 hw/intc/loongarch_pic_common.c | ||
6 | 13 | ||
7 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 14 | diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c |
8 | Acked-by: Song Gao <gaosong@loongson.cn> | ||
9 | Message-Id: <20221028014007.2718352-2-yangxiaojuan@loongson.cn> | ||
10 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
11 | --- | ||
12 | hw/loongarch/virt.c | 18 +++++++++++------- | ||
13 | include/hw/loongarch/virt.h | 3 --- | ||
14 | 2 files changed, 11 insertions(+), 10 deletions(-) | ||
15 | |||
16 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/loongarch/virt.c | 16 | --- a/hw/intc/loongarch_pch_pic.c |
19 | +++ b/hw/loongarch/virt.c | 17 | +++ b/hw/intc/loongarch_pch_pic.c |
20 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pcie_node(const LoongArchMachineState *lams) | 18 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_reset(DeviceState *d) |
21 | 1, FDT_PCI_RANGE_MMIO, 2, base_mmio, | 19 | s->int_polarity = 0x0; |
22 | 2, base_mmio, 2, size_mmio); | ||
23 | g_free(nodename); | ||
24 | - qemu_fdt_dumpdtb(ms->fdt, lams->fdt_size); | ||
25 | } | 20 | } |
26 | 21 | ||
27 | static void fdt_add_irqchip_node(LoongArchMachineState *lams) | 22 | -static void loongarch_pic_common_realize(DeviceState *dev, Error **errp) |
28 | @@ -XXX,XX +XXX,XX @@ static void loongarch_init(MachineState *machine) | 23 | -{ |
29 | MemoryRegion *address_space_mem = get_system_memory(); | 24 | - LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev); |
30 | LoongArchMachineState *lams = LOONGARCH_MACHINE(machine); | ||
31 | int i; | ||
32 | + hwaddr fdt_base; | ||
33 | |||
34 | if (!cpu_model) { | ||
35 | cpu_model = LOONGARCH_CPU_TYPE_NAME("la464"); | ||
36 | @@ -XXX,XX +XXX,XX @@ static void loongarch_init(MachineState *machine) | ||
37 | lams->machine_done.notify = virt_machine_done; | ||
38 | qemu_add_machine_init_done_notifier(&lams->machine_done); | ||
39 | fdt_add_pcie_node(lams); | ||
40 | - | 25 | - |
41 | - /* load fdt */ | 26 | - if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) { |
42 | - MemoryRegion *fdt_rom = g_new(MemoryRegion, 1); | 27 | - error_setg(errp, "Invalid 'pic_irq_num'"); |
43 | - memory_region_init_rom(fdt_rom, NULL, "fdt", VIRT_FDT_SIZE, &error_fatal); | 28 | - return; |
44 | - memory_region_add_subregion(get_system_memory(), VIRT_FDT_BASE, fdt_rom); | 29 | - } |
45 | - rom_add_blob_fixed("fdt", machine->fdt, lams->fdt_size, VIRT_FDT_BASE); | 30 | -} |
46 | + /* | 31 | - |
47 | + * Since lowmem region starts from 0, FDT base address is located | 32 | +#include "loongarch_pic_common.c" |
48 | + * at 2 MiB to avoid NULL pointer access. | 33 | static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) |
49 | + * | 34 | { |
50 | + * Put the FDT into the memory map as a ROM image: this will ensure | 35 | LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev); |
51 | + * the FDT is copied again upon reset, even if addr points into RAM. | 36 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) |
52 | + */ | 37 | |
53 | + fdt_base = 2 * MiB; | ||
54 | + qemu_fdt_dumpdtb(machine->fdt, lams->fdt_size); | ||
55 | + rom_add_blob_fixed("fdt", machine->fdt, lams->fdt_size, fdt_base); | ||
56 | } | 38 | } |
57 | 39 | ||
58 | bool loongarch_is_acpi_enabled(LoongArchMachineState *lams) | 40 | -static Property loongarch_pic_common_properties[] = { |
59 | diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h | 41 | - DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0), |
60 | index XXXXXXX..XXXXXXX 100644 | 42 | - DEFINE_PROP_END_OF_LIST(), |
61 | --- a/include/hw/loongarch/virt.h | 43 | -}; |
62 | +++ b/include/hw/loongarch/virt.h | 44 | - |
45 | -static const VMStateDescription vmstate_loongarch_pic_common = { | ||
46 | - .name = "loongarch_pch_pic", | ||
47 | - .version_id = 1, | ||
48 | - .minimum_version_id = 1, | ||
49 | - .fields = (const VMStateField[]) { | ||
50 | - VMSTATE_UINT64(int_mask, LoongArchPICCommonState), | ||
51 | - VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState), | ||
52 | - VMSTATE_UINT64(intedge, LoongArchPICCommonState), | ||
53 | - VMSTATE_UINT64(intclr, LoongArchPICCommonState), | ||
54 | - VMSTATE_UINT64(auto_crtl0, LoongArchPICCommonState), | ||
55 | - VMSTATE_UINT64(auto_crtl1, LoongArchPICCommonState), | ||
56 | - VMSTATE_UINT8_ARRAY(route_entry, LoongArchPICCommonState, 64), | ||
57 | - VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPICCommonState, 64), | ||
58 | - VMSTATE_UINT64(last_intirr, LoongArchPICCommonState), | ||
59 | - VMSTATE_UINT64(intirr, LoongArchPICCommonState), | ||
60 | - VMSTATE_UINT64(intisr, LoongArchPICCommonState), | ||
61 | - VMSTATE_UINT64(int_polarity, LoongArchPICCommonState), | ||
62 | - VMSTATE_END_OF_LIST() | ||
63 | - } | ||
64 | -}; | ||
65 | - | ||
66 | static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data) | ||
67 | { | ||
68 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
69 | diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c | ||
70 | new file mode 100644 | ||
71 | index XXXXXXX..XXXXXXX | ||
72 | --- /dev/null | ||
73 | +++ b/hw/intc/loongarch_pic_common.c | ||
63 | @@ -XXX,XX +XXX,XX @@ | 74 | @@ -XXX,XX +XXX,XX @@ |
64 | #define VIRT_GED_MEM_ADDR (VIRT_GED_EVT_ADDR + ACPI_GED_EVT_SEL_LEN) | 75 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
65 | #define VIRT_GED_REG_ADDR (VIRT_GED_MEM_ADDR + MEMORY_HOTPLUG_IO_LEN) | 76 | +/* |
66 | 77 | + * QEMU Loongson 7A1000 I/O interrupt controller. | |
67 | -#define VIRT_FDT_BASE 0x1c400000 | 78 | + * Copyright (C) 2024 Loongson Technology Corporation Limited |
68 | -#define VIRT_FDT_SIZE 0x100000 | 79 | + */ |
69 | - | 80 | + |
70 | struct LoongArchMachineState { | 81 | +static void loongarch_pic_common_realize(DeviceState *dev, Error **errp) |
71 | /*< private >*/ | 82 | +{ |
72 | MachineState parent_obj; | 83 | + LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev); |
84 | + | ||
85 | + if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) { | ||
86 | + error_setg(errp, "Invalid 'pic_irq_num'"); | ||
87 | + return; | ||
88 | + } | ||
89 | +} | ||
90 | + | ||
91 | +static Property loongarch_pic_common_properties[] = { | ||
92 | + DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPICCommonState, irq_num, 0), | ||
93 | + DEFINE_PROP_END_OF_LIST(), | ||
94 | +}; | ||
95 | + | ||
96 | +static const VMStateDescription vmstate_loongarch_pic_common = { | ||
97 | + .name = "loongarch_pch_pic", | ||
98 | + .version_id = 1, | ||
99 | + .minimum_version_id = 1, | ||
100 | + .fields = (const VMStateField[]) { | ||
101 | + VMSTATE_UINT64(int_mask, LoongArchPICCommonState), | ||
102 | + VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState), | ||
103 | + VMSTATE_UINT64(intedge, LoongArchPICCommonState), | ||
104 | + VMSTATE_UINT64(intclr, LoongArchPICCommonState), | ||
105 | + VMSTATE_UINT64(auto_crtl0, LoongArchPICCommonState), | ||
106 | + VMSTATE_UINT64(auto_crtl1, LoongArchPICCommonState), | ||
107 | + VMSTATE_UINT8_ARRAY(route_entry, LoongArchPICCommonState, 64), | ||
108 | + VMSTATE_UINT8_ARRAY(htmsi_vector, LoongArchPICCommonState, 64), | ||
109 | + VMSTATE_UINT64(last_intirr, LoongArchPICCommonState), | ||
110 | + VMSTATE_UINT64(intirr, LoongArchPICCommonState), | ||
111 | + VMSTATE_UINT64(intisr, LoongArchPICCommonState), | ||
112 | + VMSTATE_UINT64(int_polarity, LoongArchPICCommonState), | ||
113 | + VMSTATE_END_OF_LIST() | ||
114 | + } | ||
115 | +}; | ||
73 | -- | 116 | -- |
74 | 2.31.1 | 117 | 2.43.5 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set TYPE_LOONGARCH_PIC inherit from TYPE_LOONGARCH_PIC_COMMON object, | ||
2 | it shares vmsate and property of TYPE_LOONGARCH_PIC_COMMON, and has | ||
3 | its own realize() function. | ||
1 | 4 | ||
5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> | ||
6 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
7 | --- | ||
8 | hw/intc/loongarch_pch_pic.c | 38 ++++++++++++-------------- | ||
9 | hw/intc/loongarch_pic_common.c | 32 +++++++++++++++++++++- | ||
10 | hw/intc/meson.build | 2 +- | ||
11 | include/hw/intc/loongarch_pch_pic.h | 21 +++++++++++--- | ||
12 | include/hw/intc/loongarch_pic_common.h | 10 +++++++ | ||
13 | 5 files changed, 77 insertions(+), 26 deletions(-) | ||
14 | |||
15 | diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/loongarch_pch_pic.c | ||
18 | +++ b/hw/intc/loongarch_pch_pic.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_reset(DeviceState *d) | ||
20 | s->int_polarity = 0x0; | ||
21 | } | ||
22 | |||
23 | -#include "loongarch_pic_common.c" | ||
24 | -static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) | ||
25 | +static void loongarch_pic_realize(DeviceState *dev, Error **errp) | ||
26 | { | ||
27 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev); | ||
28 | - SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
29 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev); | ||
30 | + LoongarchPICClass *lpc = LOONGARCH_PIC_GET_CLASS(dev); | ||
31 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
32 | Error *local_err = NULL; | ||
33 | |||
34 | - loongarch_pic_common_realize(dev, &local_err); | ||
35 | + lpc->parent_realize(dev, &local_err); | ||
36 | if (local_err) { | ||
37 | error_propagate(errp, local_err); | ||
38 | return; | ||
39 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp) | ||
40 | |||
41 | } | ||
42 | |||
43 | -static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data) | ||
44 | +static void loongarch_pic_class_init(ObjectClass *klass, void *data) | ||
45 | { | ||
46 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
47 | + LoongarchPICClass *lpc = LOONGARCH_PIC_CLASS(klass); | ||
48 | |||
49 | - dc->realize = loongarch_pch_pic_realize; | ||
50 | device_class_set_legacy_reset(dc, loongarch_pch_pic_reset); | ||
51 | - dc->vmsd = &vmstate_loongarch_pic_common; | ||
52 | - device_class_set_props(dc, loongarch_pic_common_properties); | ||
53 | + device_class_set_parent_realize(dc, loongarch_pic_realize, | ||
54 | + &lpc->parent_realize); | ||
55 | } | ||
56 | |||
57 | -static const TypeInfo loongarch_pch_pic_info = { | ||
58 | - .name = TYPE_LOONGARCH_PCH_PIC, | ||
59 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
60 | - .instance_size = sizeof(LoongArchPCHPIC), | ||
61 | - .class_init = loongarch_pch_pic_class_init, | ||
62 | +static const TypeInfo loongarch_pic_types[] = { | ||
63 | + { | ||
64 | + .name = TYPE_LOONGARCH_PIC, | ||
65 | + .parent = TYPE_LOONGARCH_PIC_COMMON, | ||
66 | + .instance_size = sizeof(LoongarchPICState), | ||
67 | + .class_size = sizeof(LoongarchPICClass), | ||
68 | + .class_init = loongarch_pic_class_init, | ||
69 | + } | ||
70 | }; | ||
71 | |||
72 | -static void loongarch_pch_pic_register_types(void) | ||
73 | -{ | ||
74 | - type_register_static(&loongarch_pch_pic_info); | ||
75 | -} | ||
76 | - | ||
77 | -type_init(loongarch_pch_pic_register_types) | ||
78 | +DEFINE_TYPES(loongarch_pic_types) | ||
79 | diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/intc/loongarch_pic_common.c | ||
82 | +++ b/hw/intc/loongarch_pic_common.c | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | * Copyright (C) 2024 Loongson Technology Corporation Limited | ||
85 | */ | ||
86 | |||
87 | +#include "qemu/osdep.h" | ||
88 | +#include "qapi/error.h" | ||
89 | +#include "hw/intc/loongarch_pic_common.h" | ||
90 | +#include "hw/qdev-properties.h" | ||
91 | +#include "migration/vmstate.h" | ||
92 | + | ||
93 | static void loongarch_pic_common_realize(DeviceState *dev, Error **errp) | ||
94 | { | ||
95 | - LoongArchPICCommonState *s = LOONGARCH_PCH_PIC(dev); | ||
96 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev); | ||
97 | |||
98 | if (!s->irq_num || s->irq_num > VIRT_PCH_PIC_IRQ_NUM) { | ||
99 | error_setg(errp, "Invalid 'pic_irq_num'"); | ||
100 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_loongarch_pic_common = { | ||
101 | VMSTATE_END_OF_LIST() | ||
102 | } | ||
103 | }; | ||
104 | + | ||
105 | +static void loongarch_pic_common_class_init(ObjectClass *klass, void *data) | ||
106 | +{ | ||
107 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
108 | + LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_CLASS(klass); | ||
109 | + | ||
110 | + device_class_set_parent_realize(dc, loongarch_pic_common_realize, | ||
111 | + &lpcc->parent_realize); | ||
112 | + device_class_set_props(dc, loongarch_pic_common_properties); | ||
113 | + dc->vmsd = &vmstate_loongarch_pic_common; | ||
114 | +} | ||
115 | + | ||
116 | +static const TypeInfo loongarch_pic_common_types[] = { | ||
117 | + { | ||
118 | + .name = TYPE_LOONGARCH_PIC_COMMON, | ||
119 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
120 | + .instance_size = sizeof(LoongArchPICCommonState), | ||
121 | + .class_size = sizeof(LoongArchPICCommonClass), | ||
122 | + .class_init = loongarch_pic_common_class_init, | ||
123 | + .abstract = true, | ||
124 | + } | ||
125 | +}; | ||
126 | + | ||
127 | +DEFINE_TYPES(loongarch_pic_common_types) | ||
128 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/hw/intc/meson.build | ||
131 | +++ b/hw/intc/meson.build | ||
132 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) | ||
133 | specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c')) | ||
134 | specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c')) | ||
135 | specific_ss.add(when: 'CONFIG_LOONGARCH_IPI', if_true: files('loongarch_ipi.c')) | ||
136 | -specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_PIC', if_true: files('loongarch_pch_pic.c')) | ||
137 | +specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_PIC', if_true: files('loongarch_pch_pic.c', 'loongarch_pic_common.c')) | ||
138 | specific_ss.add(when: 'CONFIG_LOONGARCH_PCH_MSI', if_true: files('loongarch_pch_msi.c')) | ||
139 | specific_ss.add(when: 'CONFIG_LOONGARCH_EXTIOI', if_true: files('loongarch_extioi.c')) | ||
140 | diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/include/hw/intc/loongarch_pch_pic.h | ||
143 | +++ b/include/hw/intc/loongarch_pch_pic.h | ||
144 | @@ -XXX,XX +XXX,XX @@ | ||
145 | |||
146 | #include "hw/intc/loongarch_pic_common.h" | ||
147 | |||
148 | -#define LoongArchPCHPIC LoongArchPICCommonState | ||
149 | -#define TYPE_LOONGARCH_PCH_PIC "loongarch_pch_pic" | ||
150 | -#define PCH_PIC_NAME(name) TYPE_LOONGARCH_PCH_PIC#name | ||
151 | -OBJECT_DECLARE_SIMPLE_TYPE(LoongArchPCHPIC, LOONGARCH_PCH_PIC) | ||
152 | +#define TYPE_LOONGARCH_PIC "loongarch_pic" | ||
153 | +#define PCH_PIC_NAME(name) TYPE_LOONGARCH_PIC#name | ||
154 | +OBJECT_DECLARE_TYPE(LoongarchPICState, LoongarchPICClass, LOONGARCH_PIC) | ||
155 | + | ||
156 | +struct LoongarchPICState { | ||
157 | + LoongArchPICCommonState parent_obj; | ||
158 | +}; | ||
159 | + | ||
160 | +struct LoongarchPICClass { | ||
161 | + LoongArchPICCommonClass parent_class; | ||
162 | + | ||
163 | + DeviceRealize parent_realize; | ||
164 | +}; | ||
165 | + | ||
166 | +#define TYPE_LOONGARCH_PCH_PIC TYPE_LOONGARCH_PIC | ||
167 | +typedef struct LoongArchPICCommonState LoongArchPCHPIC; | ||
168 | +#define LOONGARCH_PCH_PIC(obj) ((struct LoongArchPICCommonState *)(obj)) | ||
169 | |||
170 | #endif /* HW_LOONGARCH_PCH_PIC_H */ | ||
171 | diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h | ||
172 | index XXXXXXX..XXXXXXX 100644 | ||
173 | --- a/include/hw/intc/loongarch_pic_common.h | ||
174 | +++ b/include/hw/intc/loongarch_pic_common.h | ||
175 | @@ -XXX,XX +XXX,XX @@ | ||
176 | #define POL_LO_START 0x40 | ||
177 | #define POL_HI_START 0x44 | ||
178 | |||
179 | +#define TYPE_LOONGARCH_PIC_COMMON "loongarch_pic_common" | ||
180 | +OBJECT_DECLARE_TYPE(LoongArchPICCommonState, | ||
181 | + LoongArchPICCommonClass, LOONGARCH_PIC_COMMON) | ||
182 | + | ||
183 | struct LoongArchPICCommonState { | ||
184 | SysBusDevice parent_obj; | ||
185 | |||
186 | @@ -XXX,XX +XXX,XX @@ struct LoongArchPICCommonState { | ||
187 | MemoryRegion iomem8; | ||
188 | unsigned int irq_num; | ||
189 | }; | ||
190 | + | ||
191 | +struct LoongArchPICCommonClass { | ||
192 | + SysBusDeviceClass parent_class; | ||
193 | + | ||
194 | + DeviceRealize parent_realize; | ||
195 | +}; | ||
196 | #endif /* HW_LOONGARCH_PIC_COMMON_H */ | ||
197 | -- | ||
198 | 2.43.5 | diff view generated by jsdifflib |
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 1 | Add vmstate pre_save and post_load interfaces, which can be used |
---|---|---|---|
2 | by pic kvm driver in future. | ||
2 | 3 | ||
3 | Add new items into LoongArch FDT, including rtc and uart info. | 4 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
5 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
6 | --- | ||
7 | hw/intc/loongarch_pic_common.c | 26 ++++++++++++++++++++++++++ | ||
8 | include/hw/intc/loongarch_pic_common.h | 2 ++ | ||
9 | 2 files changed, 28 insertions(+) | ||
4 | 10 | ||
5 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 11 | diff --git a/hw/intc/loongarch_pic_common.c b/hw/intc/loongarch_pic_common.c |
6 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
7 | Message-Id: <20221028014007.2718352-3-yangxiaojuan@loongson.cn> | ||
8 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
9 | --- | ||
10 | hw/loongarch/virt.c | 31 +++++++++++++++++++++++++++++++ | ||
11 | include/hw/pci-host/ls7a.h | 1 + | ||
12 | 2 files changed, 32 insertions(+) | ||
13 | |||
14 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/loongarch/virt.c | 13 | --- a/hw/intc/loongarch_pic_common.c |
17 | +++ b/hw/loongarch/virt.c | 14 | +++ b/hw/intc/loongarch_pic_common.c |
18 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "hw/display/ramfb.h" | 16 | #include "hw/qdev-properties.h" |
20 | #include "hw/mem/pc-dimm.h" | 17 | #include "migration/vmstate.h" |
21 | 18 | ||
22 | +static void fdt_add_rtc_node(LoongArchMachineState *lams) | 19 | +static int loongarch_pic_pre_save(void *opaque) |
23 | +{ | 20 | +{ |
24 | + char *nodename; | 21 | + LoongArchPICCommonState *s = (LoongArchPICCommonState *)opaque; |
25 | + hwaddr base = VIRT_RTC_REG_BASE; | 22 | + LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_GET_CLASS(s); |
26 | + hwaddr size = VIRT_RTC_LEN; | ||
27 | + MachineState *ms = MACHINE(lams); | ||
28 | + | 23 | + |
29 | + nodename = g_strdup_printf("/rtc@%" PRIx64, base); | 24 | + if (lpcc->pre_save) { |
30 | + qemu_fdt_add_subnode(ms->fdt, nodename); | 25 | + return lpcc->pre_save(s); |
31 | + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "loongson,ls7a-rtc"); | 26 | + } |
32 | + qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", 0x0, base, size); | 27 | + |
33 | + g_free(nodename); | 28 | + return 0; |
34 | +} | 29 | +} |
35 | + | 30 | + |
36 | +static void fdt_add_uart_node(LoongArchMachineState *lams) | 31 | +static int loongarch_pic_post_load(void *opaque, int version_id) |
37 | +{ | 32 | +{ |
38 | + char *nodename; | 33 | + LoongArchPICCommonState *s = (LoongArchPICCommonState *)opaque; |
39 | + hwaddr base = VIRT_UART_BASE; | 34 | + LoongArchPICCommonClass *lpcc = LOONGARCH_PIC_COMMON_GET_CLASS(s); |
40 | + hwaddr size = VIRT_UART_SIZE; | ||
41 | + MachineState *ms = MACHINE(lams); | ||
42 | + | 35 | + |
43 | + nodename = g_strdup_printf("/serial@%" PRIx64, base); | 36 | + if (lpcc->post_load) { |
44 | + qemu_fdt_add_subnode(ms->fdt, nodename); | 37 | + return lpcc->post_load(s, version_id); |
45 | + qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "ns16550a"); | 38 | + } |
46 | + qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0x0, base, 0x0, size); | 39 | + |
47 | + qemu_fdt_setprop_cell(ms->fdt, nodename, "clock-frequency", 100000000); | 40 | + return 0; |
48 | + g_free(nodename); | ||
49 | +} | 41 | +} |
50 | + | 42 | + |
51 | static void create_fdt(LoongArchMachineState *lams) | 43 | static void loongarch_pic_common_realize(DeviceState *dev, Error **errp) |
52 | { | 44 | { |
53 | MachineState *ms = MACHINE(lams); | 45 | LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(dev); |
54 | @@ -XXX,XX +XXX,XX @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState * | 46 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_loongarch_pic_common = { |
55 | qdev_get_gpio_in(pch_pic, | 47 | .name = "loongarch_pch_pic", |
56 | VIRT_UART_IRQ - PCH_PIC_IRQ_OFFSET), | 48 | .version_id = 1, |
57 | 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN); | 49 | .minimum_version_id = 1, |
58 | + fdt_add_uart_node(lams); | 50 | + .pre_save = loongarch_pic_pre_save, |
59 | 51 | + .post_load = loongarch_pic_post_load, | |
60 | /* Network init */ | 52 | .fields = (const VMStateField[]) { |
61 | for (i = 0; i < nb_nics; i++) { | 53 | VMSTATE_UINT64(int_mask, LoongArchPICCommonState), |
62 | @@ -XXX,XX +XXX,XX @@ static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineState * | 54 | VMSTATE_UINT64(htmsi_en, LoongArchPICCommonState), |
63 | sysbus_create_simple("ls7a_rtc", VIRT_RTC_REG_BASE, | 55 | diff --git a/include/hw/intc/loongarch_pic_common.h b/include/hw/intc/loongarch_pic_common.h |
64 | qdev_get_gpio_in(pch_pic, | ||
65 | VIRT_RTC_IRQ - PCH_PIC_IRQ_OFFSET)); | ||
66 | + fdt_add_rtc_node(lams); | ||
67 | |||
68 | pm_mem = g_new(MemoryRegion, 1); | ||
69 | memory_region_init_io(pm_mem, NULL, &loongarch_virt_pm_ops, | ||
70 | diff --git a/include/hw/pci-host/ls7a.h b/include/hw/pci-host/ls7a.h | ||
71 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
72 | --- a/include/hw/pci-host/ls7a.h | 57 | --- a/include/hw/intc/loongarch_pic_common.h |
73 | +++ b/include/hw/pci-host/ls7a.h | 58 | +++ b/include/hw/intc/loongarch_pic_common.h |
74 | @@ -XXX,XX +XXX,XX @@ | 59 | @@ -XXX,XX +XXX,XX @@ struct LoongArchPICCommonClass { |
75 | #define VIRT_PCI_IRQS 48 | 60 | SysBusDeviceClass parent_class; |
76 | #define VIRT_UART_IRQ (PCH_PIC_IRQ_OFFSET + 2) | 61 | |
77 | #define VIRT_UART_BASE 0x1fe001e0 | 62 | DeviceRealize parent_realize; |
78 | +#define VIRT_UART_SIZE 0X100 | 63 | + int (*pre_save)(LoongArchPICCommonState *s); |
79 | #define VIRT_RTC_IRQ (PCH_PIC_IRQ_OFFSET + 3) | 64 | + int (*post_load)(LoongArchPICCommonState *s, int version_id); |
80 | #define VIRT_MISC_REG_BASE (VIRT_PCH_REG_BASE + 0x00080000) | 65 | }; |
81 | #define VIRT_RTC_REG_BASE (VIRT_MISC_REG_BASE + 0x00050100) | 66 | #endif /* HW_LOONGARCH_PIC_COMMON_H */ |
82 | -- | 67 | -- |
83 | 2.31.1 | 68 | 2.43.5 | diff view generated by jsdifflib |
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 1 | Remove definition about LoongArchPCHPIC and LOONGARCH_PCH_PIC, and |
---|---|---|---|
2 | replace them with LoongArchPICCommonState and LOONGARCH_PIC_COMMON | ||
3 | separately. Also remove unnecessary header files. | ||
2 | 4 | ||
3 | Add TPM device for LoongArch virt machine, including | 5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
4 | establish TPM acpi info and add TYPE_TPM_TIS_SYSBUS | 6 | Reviewed-by: Song Gao <gaosong@loongson.cn> |
5 | to dynamic_sysbus_devices list. | 7 | --- |
8 | hw/intc/loongarch_pch_pic.c | 24 ++++++++++-------------- | ||
9 | hw/loongarch/virt.c | 2 +- | ||
10 | include/hw/intc/loongarch_pch_pic.h | 4 ---- | ||
11 | 3 files changed, 11 insertions(+), 19 deletions(-) | ||
6 | 12 | ||
7 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 13 | diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c |
8 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
9 | Message-Id: <20221028014007.2718352-4-yangxiaojuan@loongson.cn> | ||
10 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
11 | --- | ||
12 | hw/loongarch/acpi-build.c | 50 +++++++++++++++++++++++++++++++++++++-- | ||
13 | hw/loongarch/virt.c | 4 ++++ | ||
14 | 2 files changed, 52 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/loongarch/acpi-build.c | 15 | --- a/hw/intc/loongarch_pch_pic.c |
19 | +++ b/hw/loongarch/acpi-build.c | 16 | +++ b/hw/intc/loongarch_pch_pic.c |
20 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
21 | 18 | ||
22 | #include "hw/acpi/generic_event_device.h" | 19 | #include "qemu/osdep.h" |
23 | #include "hw/pci-host/gpex.h" | 20 | #include "qemu/bitops.h" |
24 | +#include "sysemu/tpm.h" | 21 | -#include "hw/sysbus.h" |
25 | +#include "hw/platform-bus.h" | 22 | -#include "hw/loongarch/virt.h" |
26 | +#include "hw/acpi/aml-build.h" | 23 | -#include "hw/pci-host/ls7a.h" |
27 | 24 | #include "hw/irq.h" | |
28 | #define ACPI_BUILD_ALIGN_SIZE 0x1000 | 25 | #include "hw/intc/loongarch_pch_pic.h" |
29 | #define ACPI_BUILD_TABLE_SIZE 0x20000 | 26 | -#include "hw/qdev-properties.h" |
30 | @@ -XXX,XX +XXX,XX @@ static void build_pci_device_aml(Aml *scope, LoongArchMachineState *lams) | 27 | -#include "migration/vmstate.h" |
31 | acpi_dsdt_add_gpex(scope, &cfg); | 28 | #include "trace.h" |
32 | } | 29 | #include "qapi/error.h" |
33 | 30 | ||
34 | +#ifdef CONFIG_TPM | 31 | -static void pch_pic_update_irq(LoongArchPCHPIC *s, uint64_t mask, int level) |
35 | +static void acpi_dsdt_add_tpm(Aml *scope, LoongArchMachineState *vms) | 32 | +static void pch_pic_update_irq(LoongArchPICCommonState *s, uint64_t mask, |
36 | +{ | 33 | + int level) |
37 | + PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev); | 34 | { |
38 | + hwaddr pbus_base = VIRT_PLATFORM_BUS_BASEADDRESS; | 35 | uint64_t val; |
39 | + SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find()); | 36 | int irq; |
40 | + MemoryRegion *sbdev_mr; | 37 | @@ -XXX,XX +XXX,XX @@ static void pch_pic_update_irq(LoongArchPCHPIC *s, uint64_t mask, int level) |
41 | + hwaddr tpm_base; | 38 | |
42 | + | 39 | static void pch_pic_irq_handler(void *opaque, int irq, int level) |
43 | + if (!sbdev) { | 40 | { |
44 | + return; | 41 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); |
45 | + } | 42 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); |
46 | + | 43 | uint64_t mask = 1ULL << irq; |
47 | + tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0); | 44 | |
48 | + assert(tpm_base != -1); | 45 | assert(irq < s->irq_num); |
49 | + | 46 | @@ -XXX,XX +XXX,XX @@ static void pch_pic_irq_handler(void *opaque, int irq, int level) |
50 | + tpm_base += pbus_base; | 47 | static uint64_t loongarch_pch_pic_low_readw(void *opaque, hwaddr addr, |
51 | + | 48 | unsigned size) |
52 | + sbdev_mr = sysbus_mmio_get_region(sbdev, 0); | 49 | { |
53 | + | 50 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); |
54 | + Aml *dev = aml_device("TPM0"); | 51 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); |
55 | + aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101"))); | 52 | uint64_t val = 0; |
56 | + aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device"))); | 53 | uint32_t offset = addr & 0xfff; |
57 | + aml_append(dev, aml_name_decl("_UID", aml_int(0))); | 54 | |
58 | + | 55 | @@ -XXX,XX +XXX,XX @@ static uint64_t get_writew_val(uint64_t value, uint32_t target, bool hi) |
59 | + Aml *crs = aml_resource_template(); | 56 | static void loongarch_pch_pic_low_writew(void *opaque, hwaddr addr, |
60 | + aml_append(crs, | 57 | uint64_t value, unsigned size) |
61 | + aml_memory32_fixed(tpm_base, | 58 | { |
62 | + (uint32_t)memory_region_size(sbdev_mr), | 59 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); |
63 | + AML_READ_WRITE)); | 60 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); |
64 | + aml_append(dev, aml_name_decl("_CRS", crs)); | 61 | uint32_t offset, old_valid, data = (uint32_t)value; |
65 | + aml_append(scope, dev); | 62 | uint64_t old, int_mask; |
66 | +} | 63 | offset = addr & 0xfff; |
67 | +#endif | 64 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_low_writew(void *opaque, hwaddr addr, |
68 | + | 65 | static uint64_t loongarch_pch_pic_high_readw(void *opaque, hwaddr addr, |
69 | /* build DSDT */ | 66 | unsigned size) |
70 | static void | 67 | { |
71 | build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) | 68 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); |
72 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) | 69 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); |
73 | build_uart_device_aml(dsdt); | 70 | uint64_t val = 0; |
74 | build_pci_device_aml(dsdt, lams); | 71 | uint32_t offset = addr & 0xfff; |
75 | build_la_ged_aml(dsdt, machine); | 72 | |
76 | - | 73 | @@ -XXX,XX +XXX,XX @@ static uint64_t loongarch_pch_pic_high_readw(void *opaque, hwaddr addr, |
77 | +#ifdef CONFIG_TPM | 74 | static void loongarch_pch_pic_high_writew(void *opaque, hwaddr addr, |
78 | + acpi_dsdt_add_tpm(dsdt, lams); | 75 | uint64_t value, unsigned size) |
79 | +#endif | 76 | { |
80 | /* System State Package */ | 77 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); |
81 | scope = aml_scope("\\"); | 78 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); |
82 | pkg = aml_package(4); | 79 | uint32_t offset, data = (uint32_t)value; |
83 | @@ -XXX,XX +XXX,XX @@ static void acpi_build(AcpiBuildTables *tables, MachineState *machine) | 80 | offset = addr & 0xfff; |
84 | build_mcfg(tables_blob, tables->linker, &mcfg, lams->oem_id, | 81 | |
85 | lams->oem_table_id); | 82 | @@ -XXX,XX +XXX,XX @@ static void loongarch_pch_pic_high_writew(void *opaque, hwaddr addr, |
86 | } | 83 | static uint64_t loongarch_pch_pic_readb(void *opaque, hwaddr addr, |
87 | - | 84 | unsigned size) |
88 | + /* TPM info */ | 85 | { |
89 | + if (tpm_get_version(tpm_find()) == TPM_VERSION_2_0) { | 86 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); |
90 | + acpi_add_table(table_offsets, tables_blob); | 87 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); |
91 | + build_tpm2(tables_blob, tables->linker, | 88 | uint64_t val = 0; |
92 | + tables->tcpalog, lams->oem_id, | 89 | uint32_t offset = (addr & 0xfff) + PCH_PIC_ROUTE_ENTRY_OFFSET; |
93 | + lams->oem_table_id); | 90 | int64_t offset_tmp; |
94 | + } | 91 | @@ -XXX,XX +XXX,XX @@ static uint64_t loongarch_pch_pic_readb(void *opaque, hwaddr addr, |
95 | /* Add tables supplied by user (if any) */ | 92 | static void loongarch_pch_pic_writeb(void *opaque, hwaddr addr, |
96 | for (u = acpi_table_first(); u; u = acpi_table_next(u)) { | 93 | uint64_t data, unsigned size) |
97 | unsigned len = acpi_table_len(u); | 94 | { |
95 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque); | ||
96 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); | ||
97 | int32_t offset_tmp; | ||
98 | uint32_t offset = (addr & 0xfff) + PCH_PIC_ROUTE_ENTRY_OFFSET; | ||
99 | |||
100 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps loongarch_pch_pic_reg8_ops = { | ||
101 | |||
102 | static void loongarch_pch_pic_reset(DeviceState *d) | ||
103 | { | ||
104 | - LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(d); | ||
105 | + LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(d); | ||
106 | int i; | ||
107 | |||
108 | s->int_mask = -1; | ||
98 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c | 109 | diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c |
99 | index XXXXXXX..XXXXXXX 100644 | 110 | index XXXXXXX..XXXXXXX 100644 |
100 | --- a/hw/loongarch/virt.c | 111 | --- a/hw/loongarch/virt.c |
101 | +++ b/hw/loongarch/virt.c | 112 | +++ b/hw/loongarch/virt.c |
102 | @@ -XXX,XX +XXX,XX @@ | 113 | @@ -XXX,XX +XXX,XX @@ static void virt_irq_init(LoongArchVirtMachineState *lvms) |
103 | #include "hw/platform-bus.h" | 114 | /* Add Extend I/O Interrupt Controller node */ |
104 | #include "hw/display/ramfb.h" | 115 | fdt_add_eiointc_node(lvms, &cpuintc_phandle, &eiointc_phandle); |
105 | #include "hw/mem/pc-dimm.h" | 116 | |
106 | +#include "sysemu/tpm.h" | 117 | - pch_pic = qdev_new(TYPE_LOONGARCH_PCH_PIC); |
107 | 118 | + pch_pic = qdev_new(TYPE_LOONGARCH_PIC); | |
108 | static void fdt_add_rtc_node(LoongArchMachineState *lams) | 119 | num = VIRT_PCH_PIC_IRQ_NUM; |
109 | { | 120 | qdev_prop_set_uint32(pch_pic, "pch_pic_irq_num", num); |
110 | @@ -XXX,XX +XXX,XX @@ static void loongarch_class_init(ObjectClass *oc, void *data) | 121 | d = SYS_BUS_DEVICE(pch_pic); |
111 | object_class_property_set_description(oc, "acpi", | 122 | diff --git a/include/hw/intc/loongarch_pch_pic.h b/include/hw/intc/loongarch_pch_pic.h |
112 | "Enable ACPI"); | 123 | index XXXXXXX..XXXXXXX 100644 |
113 | machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE); | 124 | --- a/include/hw/intc/loongarch_pch_pic.h |
114 | +#ifdef CONFIG_TPM | 125 | +++ b/include/hw/intc/loongarch_pch_pic.h |
115 | + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS); | 126 | @@ -XXX,XX +XXX,XX @@ struct LoongarchPICClass { |
116 | +#endif | 127 | DeviceRealize parent_realize; |
117 | } | 128 | }; |
118 | 129 | ||
119 | static const TypeInfo loongarch_machine_types[] = { | 130 | -#define TYPE_LOONGARCH_PCH_PIC TYPE_LOONGARCH_PIC |
131 | -typedef struct LoongArchPICCommonState LoongArchPCHPIC; | ||
132 | -#define LOONGARCH_PCH_PIC(obj) ((struct LoongArchPICCommonState *)(obj)) | ||
133 | - | ||
134 | #endif /* HW_LOONGARCH_PCH_PIC_H */ | ||
120 | -- | 135 | -- |
121 | 2.31.1 | 136 | 2.43.5 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Add common header file include/hw/intc/loongarch_extioi_common.h, and | ||
2 | move some macro definition from include/hw/intc/loongarch_extioi.h to | ||
3 | the common header file. | ||
1 | 4 | ||
5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> | ||
6 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
7 | --- | ||
8 | include/hw/intc/loongarch_extioi.h | 50 +------------------ | ||
9 | include/hw/intc/loongarch_extioi_common.h | 58 +++++++++++++++++++++++ | ||
10 | 2 files changed, 59 insertions(+), 49 deletions(-) | ||
11 | create mode 100644 include/hw/intc/loongarch_extioi_common.h | ||
12 | |||
13 | diff --git a/include/hw/intc/loongarch_extioi.h b/include/hw/intc/loongarch_extioi.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/intc/loongarch_extioi.h | ||
16 | +++ b/include/hw/intc/loongarch_extioi.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | * Copyright (C) 2021 Loongson Technology Corporation Limited | ||
19 | */ | ||
20 | |||
21 | -#include "hw/sysbus.h" | ||
22 | -#include "hw/loongarch/virt.h" | ||
23 | - | ||
24 | #ifndef LOONGARCH_EXTIOI_H | ||
25 | #define LOONGARCH_EXTIOI_H | ||
26 | |||
27 | -#define LS3A_INTC_IP 8 | ||
28 | -#define EXTIOI_IRQS (256) | ||
29 | -#define EXTIOI_IRQS_BITMAP_SIZE (256 / 8) | ||
30 | -/* irq from EXTIOI is routed to no more than 4 cpus */ | ||
31 | -#define EXTIOI_CPUS (4) | ||
32 | -/* map to ipnum per 32 irqs */ | ||
33 | -#define EXTIOI_IRQS_IPMAP_SIZE (256 / 32) | ||
34 | -#define EXTIOI_IRQS_COREMAP_SIZE 256 | ||
35 | -#define EXTIOI_IRQS_NODETYPE_COUNT 16 | ||
36 | -#define EXTIOI_IRQS_GROUP_COUNT 8 | ||
37 | - | ||
38 | -#define APIC_OFFSET 0x400 | ||
39 | -#define APIC_BASE (0x1000ULL + APIC_OFFSET) | ||
40 | - | ||
41 | -#define EXTIOI_NODETYPE_START (0x4a0 - APIC_OFFSET) | ||
42 | -#define EXTIOI_NODETYPE_END (0x4c0 - APIC_OFFSET) | ||
43 | -#define EXTIOI_IPMAP_START (0x4c0 - APIC_OFFSET) | ||
44 | -#define EXTIOI_IPMAP_END (0x4c8 - APIC_OFFSET) | ||
45 | -#define EXTIOI_ENABLE_START (0x600 - APIC_OFFSET) | ||
46 | -#define EXTIOI_ENABLE_END (0x620 - APIC_OFFSET) | ||
47 | -#define EXTIOI_BOUNCE_START (0x680 - APIC_OFFSET) | ||
48 | -#define EXTIOI_BOUNCE_END (0x6a0 - APIC_OFFSET) | ||
49 | -#define EXTIOI_ISR_START (0x700 - APIC_OFFSET) | ||
50 | -#define EXTIOI_ISR_END (0x720 - APIC_OFFSET) | ||
51 | -#define EXTIOI_COREISR_START (0x800 - APIC_OFFSET) | ||
52 | -#define EXTIOI_COREISR_END (0xB20 - APIC_OFFSET) | ||
53 | -#define EXTIOI_COREMAP_START (0xC00 - APIC_OFFSET) | ||
54 | -#define EXTIOI_COREMAP_END (0xD00 - APIC_OFFSET) | ||
55 | -#define EXTIOI_SIZE 0x800 | ||
56 | - | ||
57 | -#define EXTIOI_VIRT_BASE (0x40000000) | ||
58 | -#define EXTIOI_VIRT_SIZE (0x1000) | ||
59 | -#define EXTIOI_VIRT_FEATURES (0x0) | ||
60 | -#define EXTIOI_HAS_VIRT_EXTENSION (0) | ||
61 | -#define EXTIOI_HAS_ENABLE_OPTION (1) | ||
62 | -#define EXTIOI_HAS_INT_ENCODE (2) | ||
63 | -#define EXTIOI_HAS_CPU_ENCODE (3) | ||
64 | -#define EXTIOI_VIRT_HAS_FEATURES (BIT(EXTIOI_HAS_VIRT_EXTENSION) \ | ||
65 | - | BIT(EXTIOI_HAS_ENABLE_OPTION) \ | ||
66 | - | BIT(EXTIOI_HAS_CPU_ENCODE)) | ||
67 | -#define EXTIOI_VIRT_CONFIG (0x4) | ||
68 | -#define EXTIOI_ENABLE (1) | ||
69 | -#define EXTIOI_ENABLE_INT_ENCODE (2) | ||
70 | -#define EXTIOI_ENABLE_CPU_ENCODE (3) | ||
71 | -#define EXTIOI_VIRT_COREMAP_START (0x40) | ||
72 | -#define EXTIOI_VIRT_COREMAP_END (0x240) | ||
73 | +#include "hw/intc/loongarch_extioi_common.h" | ||
74 | |||
75 | typedef struct ExtIOICore { | ||
76 | uint32_t coreisr[EXTIOI_IRQS_GROUP_COUNT]; | ||
77 | diff --git a/include/hw/intc/loongarch_extioi_common.h b/include/hw/intc/loongarch_extioi_common.h | ||
78 | new file mode 100644 | ||
79 | index XXXXXXX..XXXXXXX | ||
80 | --- /dev/null | ||
81 | +++ b/include/hw/intc/loongarch_extioi_common.h | ||
82 | @@ -XXX,XX +XXX,XX @@ | ||
83 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
84 | +/* | ||
85 | + * LoongArch 3A5000 ext interrupt controller definitions | ||
86 | + * Copyright (C) 2024 Loongson Technology Corporation Limited | ||
87 | + */ | ||
88 | + | ||
89 | +#ifndef LOONGARCH_EXTIOI_COMMON_H | ||
90 | +#define LOONGARCH_EXTIOI_COMMON_H | ||
91 | + | ||
92 | +#include "hw/sysbus.h" | ||
93 | +#include "hw/loongarch/virt.h" | ||
94 | + | ||
95 | +#define LS3A_INTC_IP 8 | ||
96 | +#define EXTIOI_IRQS (256) | ||
97 | +#define EXTIOI_IRQS_BITMAP_SIZE (256 / 8) | ||
98 | +/* irq from EXTIOI is routed to no more than 4 cpus */ | ||
99 | +#define EXTIOI_CPUS (4) | ||
100 | +/* map to ipnum per 32 irqs */ | ||
101 | +#define EXTIOI_IRQS_IPMAP_SIZE (256 / 32) | ||
102 | +#define EXTIOI_IRQS_COREMAP_SIZE 256 | ||
103 | +#define EXTIOI_IRQS_NODETYPE_COUNT 16 | ||
104 | +#define EXTIOI_IRQS_GROUP_COUNT 8 | ||
105 | + | ||
106 | +#define APIC_OFFSET 0x400 | ||
107 | +#define APIC_BASE (0x1000ULL + APIC_OFFSET) | ||
108 | +#define EXTIOI_NODETYPE_START (0x4a0 - APIC_OFFSET) | ||
109 | +#define EXTIOI_NODETYPE_END (0x4c0 - APIC_OFFSET) | ||
110 | +#define EXTIOI_IPMAP_START (0x4c0 - APIC_OFFSET) | ||
111 | +#define EXTIOI_IPMAP_END (0x4c8 - APIC_OFFSET) | ||
112 | +#define EXTIOI_ENABLE_START (0x600 - APIC_OFFSET) | ||
113 | +#define EXTIOI_ENABLE_END (0x620 - APIC_OFFSET) | ||
114 | +#define EXTIOI_BOUNCE_START (0x680 - APIC_OFFSET) | ||
115 | +#define EXTIOI_BOUNCE_END (0x6a0 - APIC_OFFSET) | ||
116 | +#define EXTIOI_ISR_START (0x700 - APIC_OFFSET) | ||
117 | +#define EXTIOI_ISR_END (0x720 - APIC_OFFSET) | ||
118 | +#define EXTIOI_COREISR_START (0x800 - APIC_OFFSET) | ||
119 | +#define EXTIOI_COREISR_END (0xB20 - APIC_OFFSET) | ||
120 | +#define EXTIOI_COREMAP_START (0xC00 - APIC_OFFSET) | ||
121 | +#define EXTIOI_COREMAP_END (0xD00 - APIC_OFFSET) | ||
122 | +#define EXTIOI_SIZE 0x800 | ||
123 | + | ||
124 | +#define EXTIOI_VIRT_BASE (0x40000000) | ||
125 | +#define EXTIOI_VIRT_SIZE (0x1000) | ||
126 | +#define EXTIOI_VIRT_FEATURES (0x0) | ||
127 | +#define EXTIOI_HAS_VIRT_EXTENSION (0) | ||
128 | +#define EXTIOI_HAS_ENABLE_OPTION (1) | ||
129 | +#define EXTIOI_HAS_INT_ENCODE (2) | ||
130 | +#define EXTIOI_HAS_CPU_ENCODE (3) | ||
131 | +#define EXTIOI_VIRT_HAS_FEATURES (BIT(EXTIOI_HAS_VIRT_EXTENSION) \ | ||
132 | + | BIT(EXTIOI_HAS_ENABLE_OPTION) \ | ||
133 | + | BIT(EXTIOI_HAS_CPU_ENCODE)) | ||
134 | +#define EXTIOI_VIRT_CONFIG (0x4) | ||
135 | +#define EXTIOI_ENABLE (1) | ||
136 | +#define EXTIOI_ENABLE_INT_ENCODE (2) | ||
137 | +#define EXTIOI_ENABLE_CPU_ENCODE (3) | ||
138 | +#define EXTIOI_VIRT_COREMAP_START (0x40) | ||
139 | +#define EXTIOI_VIRT_COREMAP_END (0x240) | ||
140 | +#endif /* LOONGARCH_EXTIOI_H */ | ||
141 | -- | ||
142 | 2.43.5 | diff view generated by jsdifflib |
1 | When the address is invalid address, We should set exception_index | 1 | Move definiton of structure LoongArchExtIOI from header file loongarch_extioi.h |
---|---|---|---|
2 | according to MMUAccessType, and EXCCODE_ADEF need't update badinstr. | 2 | to file loongarch_extioi_common.h. |
3 | Otherwise, The system enters an infinite loop. e.g: | ||
4 | run test.c on system mode | ||
5 | test.c: | ||
6 | #include<stdio.h> | ||
7 | 3 | ||
8 | void (*func)(int *); | 4 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
5 | Reviewed-by: Song Gao <gaosong@loongson.cn> | ||
6 | --- | ||
7 | include/hw/intc/loongarch_extioi.h | 26 ---------------------- | ||
8 | include/hw/intc/loongarch_extioi_common.h | 27 +++++++++++++++++++++++ | ||
9 | 2 files changed, 27 insertions(+), 26 deletions(-) | ||
9 | 10 | ||
10 | int main() | 11 | diff --git a/include/hw/intc/loongarch_extioi.h b/include/hw/intc/loongarch_extioi.h |
11 | { | ||
12 | int i = 8; | ||
13 | void *ptr = (void *)0x4000000000000000; | ||
14 | func = ptr; | ||
15 | func(&i); | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-ID: <20221101073210.3934280-2-gaosong@loongson.cn> | ||
22 | --- | ||
23 | target/loongarch/cpu.c | 1 + | ||
24 | target/loongarch/tlb_helper.c | 5 +++-- | ||
25 | 2 files changed, 4 insertions(+), 2 deletions(-) | ||
26 | |||
27 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/loongarch/cpu.c | 13 | --- a/include/hw/intc/loongarch_extioi.h |
30 | +++ b/target/loongarch/cpu.c | 14 | +++ b/include/hw/intc/loongarch_extioi.h |
31 | @@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_do_interrupt(CPUState *cs) | 15 | @@ -XXX,XX +XXX,XX @@ |
32 | } | 16 | |
33 | QEMU_FALLTHROUGH; | 17 | #include "hw/intc/loongarch_extioi_common.h" |
34 | case EXCCODE_PIF: | 18 | |
35 | + case EXCCODE_ADEF: | 19 | -typedef struct ExtIOICore { |
36 | cause = cs->exception_index; | 20 | - uint32_t coreisr[EXTIOI_IRQS_GROUP_COUNT]; |
37 | update_badinstr = 0; | 21 | - DECLARE_BITMAP(sw_isr[LS3A_INTC_IP], EXTIOI_IRQS); |
38 | break; | 22 | - qemu_irq parent_irq[LS3A_INTC_IP]; |
39 | diff --git a/target/loongarch/tlb_helper.c b/target/loongarch/tlb_helper.c | 23 | -} ExtIOICore; |
24 | - | ||
25 | #define TYPE_LOONGARCH_EXTIOI "loongarch.extioi" | ||
26 | OBJECT_DECLARE_SIMPLE_TYPE(LoongArchExtIOI, LOONGARCH_EXTIOI) | ||
27 | -struct LoongArchExtIOI { | ||
28 | - SysBusDevice parent_obj; | ||
29 | - uint32_t num_cpu; | ||
30 | - uint32_t features; | ||
31 | - uint32_t status; | ||
32 | - /* hardware state */ | ||
33 | - uint32_t nodetype[EXTIOI_IRQS_NODETYPE_COUNT / 2]; | ||
34 | - uint32_t bounce[EXTIOI_IRQS_GROUP_COUNT]; | ||
35 | - uint32_t isr[EXTIOI_IRQS / 32]; | ||
36 | - uint32_t enable[EXTIOI_IRQS / 32]; | ||
37 | - uint32_t ipmap[EXTIOI_IRQS_IPMAP_SIZE / 4]; | ||
38 | - uint32_t coremap[EXTIOI_IRQS / 4]; | ||
39 | - uint32_t sw_pending[EXTIOI_IRQS / 32]; | ||
40 | - uint8_t sw_ipmap[EXTIOI_IRQS_IPMAP_SIZE]; | ||
41 | - uint8_t sw_coremap[EXTIOI_IRQS]; | ||
42 | - qemu_irq irq[EXTIOI_IRQS]; | ||
43 | - ExtIOICore *cpu; | ||
44 | - MemoryRegion extioi_system_mem; | ||
45 | - MemoryRegion virt_extend; | ||
46 | -}; | ||
47 | #endif /* LOONGARCH_EXTIOI_H */ | ||
48 | diff --git a/include/hw/intc/loongarch_extioi_common.h b/include/hw/intc/loongarch_extioi_common.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/loongarch/tlb_helper.c | 50 | --- a/include/hw/intc/loongarch_extioi_common.h |
42 | +++ b/target/loongarch/tlb_helper.c | 51 | +++ b/include/hw/intc/loongarch_extioi_common.h |
43 | @@ -XXX,XX +XXX,XX @@ static void raise_mmu_exception(CPULoongArchState *env, target_ulong address, | 52 | @@ -XXX,XX +XXX,XX @@ |
44 | switch (tlb_error) { | 53 | #define EXTIOI_ENABLE_CPU_ENCODE (3) |
45 | default: | 54 | #define EXTIOI_VIRT_COREMAP_START (0x40) |
46 | case TLBRET_BADADDR: | 55 | #define EXTIOI_VIRT_COREMAP_END (0x240) |
47 | - cs->exception_index = EXCCODE_ADEM; | 56 | + |
48 | + cs->exception_index = access_type == MMU_INST_FETCH | 57 | +typedef struct ExtIOICore { |
49 | + ? EXCCODE_ADEF : EXCCODE_ADEM; | 58 | + uint32_t coreisr[EXTIOI_IRQS_GROUP_COUNT]; |
50 | break; | 59 | + DECLARE_BITMAP(sw_isr[LS3A_INTC_IP], EXTIOI_IRQS); |
51 | case TLBRET_NOMATCH: | 60 | + qemu_irq parent_irq[LS3A_INTC_IP]; |
52 | /* No TLB match for a mapped address */ | 61 | +} ExtIOICore; |
53 | @@ -XXX,XX +XXX,XX @@ bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 62 | + |
54 | CPULoongArchState *env = &cpu->env; | 63 | +struct LoongArchExtIOI { |
55 | hwaddr physical; | 64 | + SysBusDevice parent_obj; |
56 | int prot; | 65 | + uint32_t num_cpu; |
57 | - int ret = TLBRET_BADADDR; | 66 | + uint32_t features; |
58 | + int ret; | 67 | + uint32_t status; |
59 | 68 | + /* hardware state */ | |
60 | /* Data access */ | 69 | + uint32_t nodetype[EXTIOI_IRQS_NODETYPE_COUNT / 2]; |
61 | ret = get_physical_address(env, &physical, &prot, address, | 70 | + uint32_t bounce[EXTIOI_IRQS_GROUP_COUNT]; |
71 | + uint32_t isr[EXTIOI_IRQS / 32]; | ||
72 | + uint32_t enable[EXTIOI_IRQS / 32]; | ||
73 | + uint32_t ipmap[EXTIOI_IRQS_IPMAP_SIZE / 4]; | ||
74 | + uint32_t coremap[EXTIOI_IRQS / 4]; | ||
75 | + uint32_t sw_pending[EXTIOI_IRQS / 32]; | ||
76 | + uint8_t sw_ipmap[EXTIOI_IRQS_IPMAP_SIZE]; | ||
77 | + uint8_t sw_coremap[EXTIOI_IRQS]; | ||
78 | + qemu_irq irq[EXTIOI_IRQS]; | ||
79 | + ExtIOICore *cpu; | ||
80 | + MemoryRegion extioi_system_mem; | ||
81 | + MemoryRegion virt_extend; | ||
82 | +}; | ||
83 | #endif /* LOONGARCH_EXTIOI_H */ | ||
62 | -- | 84 | -- |
63 | 2.31.1 | 85 | 2.43.5 | diff view generated by jsdifflib |
1 | We need subcodes to distinguish the same excode cs->exception_indexs, | 1 | Rename structure LoongArchExtIOI with LoongArchExtIOICommonState, |
---|---|---|---|
2 | such as EXCCODE_ADEF/EXCCODE_ADEM. | 2 | since it is defined in file loongarch_extioi_common.h |
3 | 3 | ||
4 | Signed-off-by: Song Gao <gaosong@loongson.cn> | 4 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Song Gao <gaosong@loongson.cn> |
6 | Message-ID: <20221101073210.3934280-1-gaosong@loongson.cn> | ||
7 | --- | 6 | --- |
8 | target/loongarch/cpu.c | 7 +++-- | 7 | include/hw/intc/loongarch_extioi.h | 1 + |
9 | target/loongarch/cpu.h | 58 ++++++++++++++++++++++-------------------- | 8 | include/hw/intc/loongarch_extioi_common.h | 2 +- |
10 | 2 files changed, 36 insertions(+), 29 deletions(-) | 9 | 2 files changed, 2 insertions(+), 1 deletion(-) |
11 | 10 | ||
12 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | 11 | diff --git a/include/hw/intc/loongarch_extioi.h b/include/hw/intc/loongarch_extioi.h |
13 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/loongarch/cpu.c | 13 | --- a/include/hw/intc/loongarch_extioi.h |
15 | +++ b/target/loongarch/cpu.c | 14 | +++ b/include/hw/intc/loongarch_extioi.h |
16 | @@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_do_interrupt(CPUState *cs) | 15 | @@ -XXX,XX +XXX,XX @@ |
17 | env->CSR_TLBRERA = FIELD_DP64(env->CSR_TLBRERA, CSR_TLBRERA, | 16 | |
18 | PC, (env->pc >> 2)); | 17 | #include "hw/intc/loongarch_extioi_common.h" |
19 | } else { | 18 | |
20 | - env->CSR_ESTAT = FIELD_DP64(env->CSR_ESTAT, CSR_ESTAT, ECODE, cause); | 19 | +#define LoongArchExtIOI LoongArchExtIOICommonState |
21 | + env->CSR_ESTAT = FIELD_DP64(env->CSR_ESTAT, CSR_ESTAT, ECODE, | 20 | #define TYPE_LOONGARCH_EXTIOI "loongarch.extioi" |
22 | + EXCODE_MCODE(cause)); | 21 | OBJECT_DECLARE_SIMPLE_TYPE(LoongArchExtIOI, LOONGARCH_EXTIOI) |
23 | + env->CSR_ESTAT = FIELD_DP64(env->CSR_ESTAT, CSR_ESTAT, ESUBCODE, | 22 | #endif /* LOONGARCH_EXTIOI_H */ |
24 | + EXCODE_SUBCODE(cause)); | 23 | diff --git a/include/hw/intc/loongarch_extioi_common.h b/include/hw/intc/loongarch_extioi_common.h |
25 | env->CSR_PRMD = FIELD_DP64(env->CSR_PRMD, CSR_PRMD, PPLV, | ||
26 | FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV)); | ||
27 | env->CSR_PRMD = FIELD_DP64(env->CSR_PRMD, CSR_PRMD, PIE, | ||
28 | @@ -XXX,XX +XXX,XX @@ static void loongarch_cpu_do_interrupt(CPUState *cs) | ||
29 | env->pc = env->CSR_TLBRENTRY; | ||
30 | } else { | ||
31 | env->pc = env->CSR_EENTRY; | ||
32 | - env->pc += cause * vec_size; | ||
33 | + env->pc += EXCODE_MCODE(cause) * vec_size; | ||
34 | } | ||
35 | qemu_log_mask(CPU_LOG_INT, | ||
36 | "%s: PC " TARGET_FMT_lx " ERA " TARGET_FMT_lx | ||
37 | diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/loongarch/cpu.h | 25 | --- a/include/hw/intc/loongarch_extioi_common.h |
40 | +++ b/target/loongarch/cpu.h | 26 | +++ b/include/hw/intc/loongarch_extioi_common.h |
41 | @@ -XXX,XX +XXX,XX @@ FIELD(FCSR0, CAUSE, 24, 5) | 27 | @@ -XXX,XX +XXX,XX @@ typedef struct ExtIOICore { |
42 | #define FP_DIV0 8 | 28 | qemu_irq parent_irq[LS3A_INTC_IP]; |
43 | #define FP_INVALID 16 | 29 | } ExtIOICore; |
44 | 30 | ||
45 | -#define EXCCODE_EXTERNAL_INT 64 /* plus external interrupt number */ | 31 | -struct LoongArchExtIOI { |
46 | -#define EXCCODE_INT 0 | 32 | +struct LoongArchExtIOICommonState { |
47 | -#define EXCCODE_PIL 1 | 33 | SysBusDevice parent_obj; |
48 | -#define EXCCODE_PIS 2 | 34 | uint32_t num_cpu; |
49 | -#define EXCCODE_PIF 3 | 35 | uint32_t features; |
50 | -#define EXCCODE_PME 4 | ||
51 | -#define EXCCODE_PNR 5 | ||
52 | -#define EXCCODE_PNX 6 | ||
53 | -#define EXCCODE_PPI 7 | ||
54 | -#define EXCCODE_ADEF 8 /* Different exception subcode */ | ||
55 | -#define EXCCODE_ADEM 8 | ||
56 | -#define EXCCODE_ALE 9 | ||
57 | -#define EXCCODE_BCE 10 | ||
58 | -#define EXCCODE_SYS 11 | ||
59 | -#define EXCCODE_BRK 12 | ||
60 | -#define EXCCODE_INE 13 | ||
61 | -#define EXCCODE_IPE 14 | ||
62 | -#define EXCCODE_FPD 15 | ||
63 | -#define EXCCODE_SXD 16 | ||
64 | -#define EXCCODE_ASXD 17 | ||
65 | -#define EXCCODE_FPE 18 /* Different exception subcode */ | ||
66 | -#define EXCCODE_VFPE 18 | ||
67 | -#define EXCCODE_WPEF 19 /* Different exception subcode */ | ||
68 | -#define EXCCODE_WPEM 19 | ||
69 | -#define EXCCODE_BTD 20 | ||
70 | -#define EXCCODE_BTE 21 | ||
71 | -#define EXCCODE_DBP 26 /* Reserved subcode used for debug */ | ||
72 | +#define EXCODE(code, subcode) ( ((subcode) << 6) | (code) ) | ||
73 | +#define EXCODE_MCODE(code) ( (code) & 0x3f ) | ||
74 | +#define EXCODE_SUBCODE(code) ( (code) >> 6 ) | ||
75 | + | ||
76 | +#define EXCCODE_EXTERNAL_INT 64 /* plus external interrupt number */ | ||
77 | +#define EXCCODE_INT EXCODE(0, 0) | ||
78 | +#define EXCCODE_PIL EXCODE(1, 0) | ||
79 | +#define EXCCODE_PIS EXCODE(2, 0) | ||
80 | +#define EXCCODE_PIF EXCODE(3, 0) | ||
81 | +#define EXCCODE_PME EXCODE(4, 0) | ||
82 | +#define EXCCODE_PNR EXCODE(5, 0) | ||
83 | +#define EXCCODE_PNX EXCODE(6, 0) | ||
84 | +#define EXCCODE_PPI EXCODE(7, 0) | ||
85 | +#define EXCCODE_ADEF EXCODE(8, 0) /* Different exception subcode */ | ||
86 | +#define EXCCODE_ADEM EXCODE(8, 1) | ||
87 | +#define EXCCODE_ALE EXCODE(9, 0) | ||
88 | +#define EXCCODE_BCE EXCODE(10, 0) | ||
89 | +#define EXCCODE_SYS EXCODE(11, 0) | ||
90 | +#define EXCCODE_BRK EXCODE(12, 0) | ||
91 | +#define EXCCODE_INE EXCODE(13, 0) | ||
92 | +#define EXCCODE_IPE EXCODE(14, 0) | ||
93 | +#define EXCCODE_FPD EXCODE(15, 0) | ||
94 | +#define EXCCODE_SXD EXCODE(16, 0) | ||
95 | +#define EXCCODE_ASXD EXCODE(17, 0) | ||
96 | +#define EXCCODE_FPE EXCODE(18, 0) /* Different exception subcode */ | ||
97 | +#define EXCCODE_VFPE EXCODE(18, 1) | ||
98 | +#define EXCCODE_WPEF EXCODE(19, 0) /* Different exception subcode */ | ||
99 | +#define EXCCODE_WPEM EXCODE(19, 1) | ||
100 | +#define EXCCODE_BTD EXCODE(20, 0) | ||
101 | +#define EXCCODE_BTE EXCODE(21, 0) | ||
102 | +#define EXCCODE_DBP EXCODE(26, 0) /* Reserved subcode used for debug */ | ||
103 | |||
104 | /* cpucfg[0] bits */ | ||
105 | FIELD(CPUCFG0, PRID, 0, 32) | ||
106 | -- | 36 | -- |
107 | 2.31.1 | 37 | 2.43.5 | diff view generated by jsdifflib |
1 | From: Xiaojuan Yang <yangxiaojuan@loongson.cn> | 1 | With some structure such as vmstate and property, rename LoongArchExtIOI |
---|---|---|---|
2 | with LoongArchExtIOICommonState, these common structure will be moved | ||
3 | to common file. | ||
2 | 4 | ||
3 | 1. When cpu read or write extioi COREISR reg, it should access | 5 | Signed-off-by: Bibo Mao <maobibo@loongson.cn> |
4 | the reg belonged to itself, so the cpu index of 's->coreisr' | 6 | Reviewed-by: Song Gao <gaosong@loongson.cn> |
5 | is current cpu number. Using MemTxAttrs' requester_id to get | ||
6 | the cpu index. | ||
7 | 2. it need not to mask 0x1f when calculate the coreisr array index. | ||
8 | |||
9 | Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-Id: <20221021015307.2570844-3-yangxiaojuan@loongson.cn> | ||
12 | Signed-off-by: Song Gao <gaosong@loongson.cn> | ||
13 | --- | 7 | --- |
14 | hw/intc/loongarch_extioi.c | 10 ++++++---- | 8 | hw/intc/loongarch_extioi.c | 41 +++++++++++++++++++++++--------------- |
15 | target/loongarch/iocsr_helper.c | 19 +++++++++++-------- | 9 | 1 file changed, 25 insertions(+), 16 deletions(-) |
16 | 2 files changed, 17 insertions(+), 12 deletions(-) | ||
17 | 10 | ||
18 | diff --git a/hw/intc/loongarch_extioi.c b/hw/intc/loongarch_extioi.c | 11 | diff --git a/hw/intc/loongarch_extioi.c b/hw/intc/loongarch_extioi.c |
19 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/loongarch_extioi.c | 13 | --- a/hw/intc/loongarch_extioi.c |
21 | +++ b/hw/intc/loongarch_extioi.c | 14 | +++ b/hw/intc/loongarch_extioi.c |
22 | @@ -XXX,XX +XXX,XX @@ static MemTxResult extioi_readw(void *opaque, hwaddr addr, uint64_t *data, | 15 | @@ -XXX,XX +XXX,XX @@ static int vmstate_extioi_post_load(void *opaque, int version_id) |
23 | *data = s->bounce[index]; | 16 | return 0; |
24 | break; | 17 | } |
25 | case EXTIOI_COREISR_START ... EXTIOI_COREISR_END - 1: | 18 | |
26 | - index = ((offset - EXTIOI_COREISR_START) & 0x1f) >> 2; | 19 | +static int loongarch_extioi_common_post_load(void *opaque, int version_id) |
27 | - cpu = ((offset - EXTIOI_COREISR_START) >> 8) & 0x3; | 20 | +{ |
28 | + index = (offset - EXTIOI_COREISR_START) >> 2; | 21 | + return vmstate_extioi_post_load(opaque, version_id); |
29 | + /* using attrs to get current cpu index */ | 22 | +} |
30 | + cpu = attrs.requester_id; | ||
31 | *data = s->coreisr[cpu][index]; | ||
32 | break; | ||
33 | case EXTIOI_COREMAP_START ... EXTIOI_COREMAP_END - 1: | ||
34 | @@ -XXX,XX +XXX,XX @@ static MemTxResult extioi_writew(void *opaque, hwaddr addr, | ||
35 | s->bounce[index] = val; | ||
36 | break; | ||
37 | case EXTIOI_COREISR_START ... EXTIOI_COREISR_END - 1: | ||
38 | - index = ((offset - EXTIOI_COREISR_START) & 0x1f) >> 2; | ||
39 | - cpu = ((offset - EXTIOI_COREISR_START) >> 8) & 0x3; | ||
40 | + index = (offset - EXTIOI_COREISR_START) >> 2; | ||
41 | + /* using attrs to get current cpu index */ | ||
42 | + cpu = attrs.requester_id; | ||
43 | old_data = s->coreisr[cpu][index]; | ||
44 | s->coreisr[cpu][index] = old_data & ~val; | ||
45 | /* write 1 to clear interrrupt */ | ||
46 | diff --git a/target/loongarch/iocsr_helper.c b/target/loongarch/iocsr_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/loongarch/iocsr_helper.c | ||
49 | +++ b/target/loongarch/iocsr_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #include "exec/cpu_ldst.h" | ||
52 | #include "tcg/tcg-ldst.h" | ||
53 | |||
54 | +#define GET_MEMTXATTRS(cas) \ | ||
55 | + ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index}) | ||
56 | + | 23 | + |
57 | uint64_t helper_iocsrrd_b(CPULoongArchState *env, target_ulong r_addr) | 24 | static const VMStateDescription vmstate_extioi_core = { |
58 | { | 25 | .name = "extioi-core", |
59 | return address_space_ldub(&env->address_space_iocsr, r_addr, | 26 | .version_id = 1, |
60 | - MEMTXATTRS_UNSPECIFIED, NULL); | 27 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_extioi_core = { |
61 | + GET_MEMTXATTRS(env), NULL); | 28 | }; |
62 | } | 29 | |
63 | 30 | static const VMStateDescription vmstate_loongarch_extioi = { | |
64 | uint64_t helper_iocsrrd_h(CPULoongArchState *env, target_ulong r_addr) | 31 | - .name = TYPE_LOONGARCH_EXTIOI, |
65 | { | 32 | + .name = "loongarch.extioi", |
66 | return address_space_lduw(&env->address_space_iocsr, r_addr, | 33 | .version_id = 3, |
67 | - MEMTXATTRS_UNSPECIFIED, NULL); | 34 | .minimum_version_id = 3, |
68 | + GET_MEMTXATTRS(env), NULL); | 35 | - .post_load = vmstate_extioi_post_load, |
69 | } | 36 | + .post_load = loongarch_extioi_common_post_load, |
70 | 37 | .fields = (const VMStateField[]) { | |
71 | uint64_t helper_iocsrrd_w(CPULoongArchState *env, target_ulong r_addr) | 38 | - VMSTATE_UINT32_ARRAY(bounce, LoongArchExtIOI, EXTIOI_IRQS_GROUP_COUNT), |
72 | { | 39 | - VMSTATE_UINT32_ARRAY(nodetype, LoongArchExtIOI, |
73 | return address_space_ldl(&env->address_space_iocsr, r_addr, | 40 | + VMSTATE_UINT32_ARRAY(bounce, LoongArchExtIOICommonState, |
74 | - MEMTXATTRS_UNSPECIFIED, NULL); | 41 | + EXTIOI_IRQS_GROUP_COUNT), |
75 | + GET_MEMTXATTRS(env), NULL); | 42 | + VMSTATE_UINT32_ARRAY(nodetype, LoongArchExtIOICommonState, |
76 | } | 43 | EXTIOI_IRQS_NODETYPE_COUNT / 2), |
77 | 44 | - VMSTATE_UINT32_ARRAY(enable, LoongArchExtIOI, EXTIOI_IRQS / 32), | |
78 | uint64_t helper_iocsrrd_d(CPULoongArchState *env, target_ulong r_addr) | 45 | - VMSTATE_UINT32_ARRAY(isr, LoongArchExtIOI, EXTIOI_IRQS / 32), |
79 | { | 46 | - VMSTATE_UINT32_ARRAY(ipmap, LoongArchExtIOI, EXTIOI_IRQS_IPMAP_SIZE / 4), |
80 | return address_space_ldq(&env->address_space_iocsr, r_addr, | 47 | - VMSTATE_UINT32_ARRAY(coremap, LoongArchExtIOI, EXTIOI_IRQS / 4), |
81 | - MEMTXATTRS_UNSPECIFIED, NULL); | 48 | - |
82 | + GET_MEMTXATTRS(env), NULL); | 49 | - VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, LoongArchExtIOI, num_cpu, |
83 | } | 50 | - vmstate_extioi_core, ExtIOICore), |
84 | 51 | - VMSTATE_UINT32(features, LoongArchExtIOI), | |
85 | void helper_iocsrwr_b(CPULoongArchState *env, target_ulong w_addr, | 52 | - VMSTATE_UINT32(status, LoongArchExtIOI), |
86 | target_ulong val) | 53 | + VMSTATE_UINT32_ARRAY(enable, LoongArchExtIOICommonState, |
87 | { | 54 | + EXTIOI_IRQS / 32), |
88 | address_space_stb(&env->address_space_iocsr, w_addr, | 55 | + VMSTATE_UINT32_ARRAY(isr, LoongArchExtIOICommonState, |
89 | - val, MEMTXATTRS_UNSPECIFIED, NULL); | 56 | + EXTIOI_IRQS / 32), |
90 | + val, GET_MEMTXATTRS(env), NULL); | 57 | + VMSTATE_UINT32_ARRAY(ipmap, LoongArchExtIOICommonState, |
91 | } | 58 | + EXTIOI_IRQS_IPMAP_SIZE / 4), |
92 | 59 | + VMSTATE_UINT32_ARRAY(coremap, LoongArchExtIOICommonState, | |
93 | void helper_iocsrwr_h(CPULoongArchState *env, target_ulong w_addr, | 60 | + EXTIOI_IRQS / 4), |
94 | target_ulong val) | 61 | + VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, LoongArchExtIOICommonState, |
95 | { | 62 | + num_cpu, vmstate_extioi_core, ExtIOICore), |
96 | address_space_stw(&env->address_space_iocsr, w_addr, | 63 | + VMSTATE_UINT32(features, LoongArchExtIOICommonState), |
97 | - val, MEMTXATTRS_UNSPECIFIED, NULL); | 64 | + VMSTATE_UINT32(status, LoongArchExtIOICommonState), |
98 | + val, GET_MEMTXATTRS(env), NULL); | 65 | VMSTATE_END_OF_LIST() |
99 | } | 66 | } |
100 | 67 | }; | |
101 | void helper_iocsrwr_w(CPULoongArchState *env, target_ulong w_addr, | 68 | |
102 | target_ulong val) | 69 | static Property extioi_properties[] = { |
103 | { | 70 | - DEFINE_PROP_UINT32("num-cpu", LoongArchExtIOI, num_cpu, 1), |
104 | address_space_stl(&env->address_space_iocsr, w_addr, | 71 | - DEFINE_PROP_BIT("has-virtualization-extension", LoongArchExtIOI, features, |
105 | - val, MEMTXATTRS_UNSPECIFIED, NULL); | 72 | - EXTIOI_HAS_VIRT_EXTENSION, 0), |
106 | + val, GET_MEMTXATTRS(env), NULL); | 73 | + DEFINE_PROP_UINT32("num-cpu", LoongArchExtIOICommonState, num_cpu, 1), |
107 | } | 74 | + DEFINE_PROP_BIT("has-virtualization-extension", LoongArchExtIOICommonState, |
108 | 75 | + features, EXTIOI_HAS_VIRT_EXTENSION, 0), | |
109 | void helper_iocsrwr_d(CPULoongArchState *env, target_ulong w_addr, | 76 | DEFINE_PROP_END_OF_LIST(), |
110 | target_ulong val) | 77 | }; |
111 | { | 78 | |
112 | address_space_stq(&env->address_space_iocsr, w_addr, | ||
113 | - val, MEMTXATTRS_UNSPECIFIED, NULL); | ||
114 | + val, GET_MEMTXATTRS(env), NULL); | ||
115 | } | ||
116 | -- | 79 | -- |
117 | 2.31.1 | 80 | 2.43.5 | diff view generated by jsdifflib |