1 | target-arm queue: I have a lot more still in my to-review | 1 | Hi; here's the latest target-arm queue. Mostly this is refactoring |
---|---|---|---|
2 | queue, but my rule of thumb is when I get to 50 patches or | 2 | and cleanup type patches. |
3 | so to send out what I have. | ||
4 | 3 | ||
5 | thanks | 4 | thanks |
6 | -- PMM | 5 | -- PMM |
7 | 6 | ||
8 | The following changes since commit 9a7beaad3dbba982f7a461d676b55a5c3851d312: | 7 | The following changes since commit c60be6e3e38cb36dc66129e757ec4b34152232be: |
9 | 8 | ||
10 | Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20210304' into staging (2021-03-05 10:47:46 +0000) | 9 | Merge tag 'pull-sp-20231025' of https://gitlab.com/rth7680/qemu into staging (2023-10-27 09:43:53 +0900) |
11 | 10 | ||
12 | are available in the Git repository at: | 11 | are available in the Git repository at: |
13 | 12 | ||
14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210305 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20231027 |
15 | 14 | ||
16 | for you to fetch changes up to 2c669ff88ec6733420a000103a2b8b9e93df4945: | 15 | for you to fetch changes up to df93de987f423a0ed918c425f5dbd9a25d3c6229: |
17 | 16 | ||
18 | hw/arm/mps2: Update old infocenter.arm.com URLs (2021-03-05 15:17:38 +0000) | 17 | hw/net/cadence_gem: enforce 32 bits variable size for CRC (2023-10-27 15:27:06 +0100) |
19 | 18 | ||
20 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
21 | * sbsa-ref: remove cortex-a53 from list of supported cpus | 20 | target-arm queue: |
22 | * sbsa-ref: add 'max' to list of allowed cpus | 21 | * Correct minor errors in Cortex-A710 definition |
23 | * target/arm: Add support for FEAT_SSBS, Speculative Store Bypass Safe | 22 | * Implement Neoverse N2 CPU model |
24 | * npcm7xx: add EMC model | 23 | * Refactor feature test functions out into separate header |
25 | * xlnx-zynqmp: Remove obsolete 'has_rpu' property | 24 | * Fix syndrome for FGT traps on ERET |
26 | * target/arm: Speed up aarch64 TBL/TBX | 25 | * Remove 'hw/arm/boot.h' includes from various header files |
27 | * virtio-mmio: improve virtio-mmio get_dev_path alog | 26 | * pxa2xx: Refactoring/cleanup |
28 | * target/arm: Use TCF0 and TFSRE0 for unprivileged tag checks | 27 | * Avoid using 'first_cpu' when first ARM CPU is reachable |
29 | * target/arm: Restrict v8M IDAU to TCG | 28 | * misc/led: LED state is set opposite of what is expected |
30 | * target/arm/cpu: Update coding style to make checkpatch.pl happy | 29 | * hw/net/cadence_gen: clean up to use FIELD macros |
31 | * musicpal, tc6393xb, omap_lcdc, tcx: drop dead code for non-32-bit-RGB surfaces | 30 | * hw/net/cadence_gem: perform PHY access on write only |
32 | * Add new board: mps3-an524 | 31 | * hw/net/cadence_gem: enforce 32 bits variable size for CRC |
33 | 32 | ||
34 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
35 | Doug Evans (3): | 34 | Glenn Miles (1): |
36 | hw/net: Add npcm7xx emc model | 35 | misc/led: LED state is set opposite of what is expected |
37 | hw/arm: Add npcm7xx emc model | ||
38 | tests/qtests: Add npcm7xx emc model test | ||
39 | 36 | ||
40 | Marcin Juszkiewicz (2): | 37 | Luc Michel (11): |
41 | sbsa-ref: remove cortex-a53 from list of supported cpus | 38 | hw/net/cadence_gem: use REG32 macro for register definitions |
42 | sbsa-ref: add 'max' to list of allowed cpus | 39 | hw/net/cadence_gem: use FIELD for screening registers |
40 | hw/net/cadence_gem: use FIELD to describe NWCTRL register fields | ||
41 | hw/net/cadence_gem: use FIELD to describe NWCFG register fields | ||
42 | hw/net/cadence_gem: use FIELD to describe DMACFG register fields | ||
43 | hw/net/cadence_gem: use FIELD to describe [TX|RX]STATUS register fields | ||
44 | hw/net/cadence_gem: use FIELD to describe IRQ register fields | ||
45 | hw/net/cadence_gem: use FIELD to describe DESCONF6 register fields | ||
46 | hw/net/cadence_gem: use FIELD to describe PHYMNTNC register fields | ||
47 | hw/net/cadence_gem: perform PHY access on write only | ||
48 | hw/net/cadence_gem: enforce 32 bits variable size for CRC | ||
43 | 49 | ||
44 | Peter Collingbourne (1): | 50 | Peter Maydell (9): |
45 | target/arm: Use TCF0 and TFSRE0 for unprivileged tag checks | 51 | target/arm: Correct minor errors in Cortex-A710 definition |
52 | target/arm: Implement Neoverse N2 CPU model | ||
53 | target/arm: Move feature test functions to their own header | ||
54 | target/arm: Move ID_AA64MMFR1 and ID_AA64MMFR2 tests together | ||
55 | target/arm: Move ID_AA64MMFR0 tests up to before MMFR1 and MMFR2 | ||
56 | target/arm: Move ID_AA64ISAR* test functions together | ||
57 | target/arm: Move ID_AA64PFR* tests together | ||
58 | target/arm: Move ID_AA64DFR* feature tests together | ||
59 | target/arm: Fix syndrome for FGT traps on ERET | ||
46 | 60 | ||
47 | Peter Maydell (34): | 61 | Philippe Mathieu-Daudé (20): |
48 | hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces | 62 | hw/arm/allwinner-a10: Remove 'hw/arm/boot.h' from header |
49 | hw/display/tc6393xb: Remove dead code for handling non-32bpp surfaces | 63 | hw/arm/allwinner-h3: Remove 'hw/arm/boot.h' from header |
50 | hw/display/tc6393xb: Expand out macros in template header | 64 | hw/arm/allwinner-r40: Remove 'hw/arm/boot.h' from header |
51 | hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite | 65 | hw/arm/fsl-imx25: Remove 'hw/arm/boot.h' from header |
52 | hw/display/omap_lcdc: Expand out macros in template header | 66 | hw/arm/fsl-imx31: Remove 'hw/arm/boot.h' from header |
53 | hw/display/omap_lcdc: Drop broken bigendian ifdef | 67 | hw/arm/fsl-imx6: Remove 'hw/arm/boot.h' from header |
54 | hw/display/omap_lcdc: Fix coding style issues in template header | 68 | hw/arm/fsl-imx6ul: Remove 'hw/arm/boot.h' from header |
55 | hw/display/omap_lcdc: Inline template header into C file | 69 | hw/arm/fsl-imx7: Remove 'hw/arm/boot.h' from header |
56 | hw/display/omap_lcdc: Delete unnecessary macro | 70 | hw/arm/xlnx-versal: Remove 'hw/arm/boot.h' from header |
57 | hw/display/tcx: Drop unnecessary code for handling BGR format outputs | 71 | hw/arm/xlnx-zynqmp: Remove 'hw/arm/boot.h' from header |
58 | hw/arm/mps2-tz: Make SYSCLK frequency board-specific | 72 | hw/sd/pxa2xx: Realize sysbus device before accessing it |
59 | hw/misc/mps2-scc: Support configurable number of OSCCLK values | 73 | hw/sd/pxa2xx: Do not open-code sysbus_create_simple() |
60 | hw/arm/mps2-tz: Correct the OSCCLK settings for mps2-an505 and mps2-an511 | 74 | hw/pcmcia/pxa2xx: Realize sysbus device before accessing it |
61 | hw/arm/mps2-tz: Make the OSCCLK settings be configurable per-board | 75 | hw/pcmcia/pxa2xx: Do not open-code sysbus_create_simple() |
62 | hw/misc/mps2-fpgaio: Make number of LEDs configurable by board | 76 | hw/pcmcia/pxa2xx: Inline pxa2xx_pcmcia_init() |
63 | hw/misc/mps2-fpgaio: Support SWITCH register | 77 | hw/intc/pxa2xx: Convert to Resettable interface |
64 | hw/arm/mps2-tz: Make FPGAIO switch and LED config per-board | 78 | hw/intc/pxa2xx: Pass CPU reference using QOM link property |
65 | hw/arm/mps2-tz: Condition IRQ splitting on number of CPUs, not board type | 79 | hw/intc/pxa2xx: Factor pxa2xx_pic_realize() out of pxa2xx_pic_init() |
66 | hw/arm/mps2-tz: Make number of IRQs board-specific | 80 | hw/arm/pxa2xx: Realize PXA2XX_I2C device before accessing it |
67 | hw/misc/mps2-scc: Implement CFG_REG5 and CFG_REG6 for MPS3 AN524 | 81 | hw/arm: Avoid using 'first_cpu' when first ARM CPU is reachable |
68 | hw/arm/mps2-tz: Correct wrong interrupt numbers for DMA and SPI | ||
69 | hw/arm/mps2-tz: Allow PPCPortInfo structures to specify device interrupts | ||
70 | hw/arm/mps2-tz: Move device IRQ info to data structures | ||
71 | hw/arm/mps2-tz: Size the uart-irq-orgate based on the number of UARTs | ||
72 | hw/arm/mps2-tz: Allow boards to have different PPCInfo data | ||
73 | hw/arm/mps2-tz: Make RAM arrangement board-specific | ||
74 | hw/arm/mps2-tz: Set MachineClass default_ram info from RAMInfo data | ||
75 | hw/arm/mps2-tz: Support ROMs as well as RAMs | ||
76 | hw/arm/mps2-tz: Get armv7m_load_kernel() size argument from RAMInfo | ||
77 | hw/arm/mps2-tz: Add new mps3-an524 board | ||
78 | hw/arm/mps2-tz: Stub out USB controller for mps3-an524 | ||
79 | hw/arm/mps2-tz: Provide PL031 RTC on mps3-an524 | ||
80 | docs/system/arm/mps2.rst: Document the new mps3-an524 board | ||
81 | hw/arm/mps2: Update old infocenter.arm.com URLs | ||
82 | 82 | ||
83 | Philippe Mathieu-Daudé (4): | 83 | docs/system/arm/virt.rst | 1 + |
84 | hw/arm/xlnx-zynqmp: Remove obsolete 'has_rpu' property | 84 | bsd-user/arm/target_arch.h | 1 + |
85 | hw/i2c/npcm7xx_smbus: Simplify npcm7xx_smbus_init() | 85 | include/hw/arm/allwinner-a10.h | 1 - |
86 | target/arm: Restrict v8M IDAU to TCG | 86 | include/hw/arm/allwinner-h3.h | 1 - |
87 | target/arm/cpu: Update coding style to make checkpatch.pl happy | 87 | include/hw/arm/allwinner-r40.h | 1 - |
88 | include/hw/arm/fsl-imx25.h | 1 - | ||
89 | include/hw/arm/fsl-imx31.h | 1 - | ||
90 | include/hw/arm/fsl-imx6.h | 1 - | ||
91 | include/hw/arm/fsl-imx6ul.h | 1 - | ||
92 | include/hw/arm/fsl-imx7.h | 1 - | ||
93 | include/hw/arm/pxa.h | 2 - | ||
94 | include/hw/arm/xlnx-versal.h | 1 - | ||
95 | include/hw/arm/xlnx-zynqmp.h | 1 - | ||
96 | linux-user/aarch64/target_prctl.h | 2 + | ||
97 | target/arm/cpu-features.h | 994 ++++++++++++++++++++++++++++++++++++++ | ||
98 | target/arm/cpu.h | 971 ------------------------------------- | ||
99 | target/arm/internals.h | 1 + | ||
100 | target/arm/tcg/translate.h | 2 +- | ||
101 | hw/arm/armv7m.c | 1 + | ||
102 | hw/arm/bananapi_m2u.c | 3 +- | ||
103 | hw/arm/cubieboard.c | 1 + | ||
104 | hw/arm/exynos4_boards.c | 7 +- | ||
105 | hw/arm/imx25_pdk.c | 1 + | ||
106 | hw/arm/kzm.c | 1 + | ||
107 | hw/arm/mcimx6ul-evk.c | 1 + | ||
108 | hw/arm/mcimx7d-sabre.c | 1 + | ||
109 | hw/arm/orangepi.c | 3 +- | ||
110 | hw/arm/pxa2xx.c | 17 +- | ||
111 | hw/arm/pxa2xx_pic.c | 38 +- | ||
112 | hw/arm/realview.c | 2 +- | ||
113 | hw/arm/sabrelite.c | 1 + | ||
114 | hw/arm/sbsa-ref.c | 1 + | ||
115 | hw/arm/virt.c | 1 + | ||
116 | hw/arm/xilinx_zynq.c | 2 +- | ||
117 | hw/arm/xlnx-versal-virt.c | 1 + | ||
118 | hw/arm/xlnx-zcu102.c | 1 + | ||
119 | hw/intc/armv7m_nvic.c | 1 + | ||
120 | hw/misc/led.c | 2 +- | ||
121 | hw/net/cadence_gem.c | 884 ++++++++++++++++++--------------- | ||
122 | hw/pcmcia/pxa2xx.c | 15 - | ||
123 | hw/sd/pxa2xx_mmci.c | 7 +- | ||
124 | linux-user/aarch64/cpu_loop.c | 1 + | ||
125 | linux-user/aarch64/signal.c | 1 + | ||
126 | linux-user/arm/signal.c | 1 + | ||
127 | linux-user/elfload.c | 4 + | ||
128 | linux-user/mmap.c | 4 + | ||
129 | target/arm/arch_dump.c | 1 + | ||
130 | target/arm/cpu.c | 1 + | ||
131 | target/arm/cpu64.c | 1 + | ||
132 | target/arm/debug_helper.c | 1 + | ||
133 | target/arm/gdbstub.c | 1 + | ||
134 | target/arm/helper.c | 1 + | ||
135 | target/arm/kvm64.c | 1 + | ||
136 | target/arm/machine.c | 1 + | ||
137 | target/arm/ptw.c | 1 + | ||
138 | target/arm/tcg/cpu64.c | 115 ++++- | ||
139 | target/arm/tcg/hflags.c | 1 + | ||
140 | target/arm/tcg/m_helper.c | 1 + | ||
141 | target/arm/tcg/op_helper.c | 1 + | ||
142 | target/arm/tcg/pauth_helper.c | 1 + | ||
143 | target/arm/tcg/tlb_helper.c | 1 + | ||
144 | target/arm/tcg/translate-a64.c | 4 +- | ||
145 | target/arm/vfp_helper.c | 1 + | ||
146 | 63 files changed, 1702 insertions(+), 1419 deletions(-) | ||
147 | create mode 100644 target/arm/cpu-features.h | ||
88 | 148 | ||
89 | Rebecca Cran (3): | ||
90 | target/arm: Add support for FEAT_SSBS, Speculative Store Bypass Safe | ||
91 | target/arm: Enable FEAT_SSBS for "max" AARCH64 CPU | ||
92 | target/arm: Set ID_PFR2.SSBS to 1 for "max" 32-bit CPU | ||
93 | |||
94 | Richard Henderson (1): | ||
95 | target/arm: Speed up aarch64 TBL/TBX | ||
96 | |||
97 | schspa (1): | ||
98 | virtio-mmio: improve virtio-mmio get_dev_path alog | ||
99 | |||
100 | docs/system/arm/mps2.rst | 24 +- | ||
101 | docs/system/arm/nuvoton.rst | 3 +- | ||
102 | hw/display/omap_lcd_template.h | 169 -------- | ||
103 | hw/display/tc6393xb_template.h | 72 ---- | ||
104 | include/hw/arm/armsse.h | 4 +- | ||
105 | include/hw/arm/npcm7xx.h | 2 + | ||
106 | include/hw/arm/xlnx-zynqmp.h | 2 - | ||
107 | include/hw/misc/armsse-cpuid.h | 2 +- | ||
108 | include/hw/misc/armsse-mhu.h | 2 +- | ||
109 | include/hw/misc/iotkit-secctl.h | 2 +- | ||
110 | include/hw/misc/iotkit-sysctl.h | 2 +- | ||
111 | include/hw/misc/iotkit-sysinfo.h | 2 +- | ||
112 | include/hw/misc/mps2-fpgaio.h | 8 +- | ||
113 | include/hw/misc/mps2-scc.h | 10 +- | ||
114 | include/hw/net/npcm7xx_emc.h | 286 +++++++++++++ | ||
115 | include/ui/console.h | 10 - | ||
116 | target/arm/cpu.h | 15 +- | ||
117 | target/arm/helper-a64.h | 2 +- | ||
118 | target/arm/internals.h | 6 + | ||
119 | hw/arm/mps2-tz.c | 632 +++++++++++++++++++++++----- | ||
120 | hw/arm/mps2.c | 5 + | ||
121 | hw/arm/musicpal.c | 64 ++- | ||
122 | hw/arm/npcm7xx.c | 50 ++- | ||
123 | hw/arm/sbsa-ref.c | 2 +- | ||
124 | hw/arm/xlnx-zynqmp.c | 6 - | ||
125 | hw/display/omap_lcdc.c | 129 +++++- | ||
126 | hw/display/tc6393xb.c | 48 +-- | ||
127 | hw/display/tcx.c | 31 +- | ||
128 | hw/i2c/npcm7xx_smbus.c | 1 - | ||
129 | hw/misc/armsse-cpuid.c | 2 +- | ||
130 | hw/misc/armsse-mhu.c | 2 +- | ||
131 | hw/misc/iotkit-sysctl.c | 2 +- | ||
132 | hw/misc/iotkit-sysinfo.c | 2 +- | ||
133 | hw/misc/mps2-fpgaio.c | 43 +- | ||
134 | hw/misc/mps2-scc.c | 93 ++++- | ||
135 | hw/net/npcm7xx_emc.c | 857 ++++++++++++++++++++++++++++++++++++++ | ||
136 | hw/virtio/virtio-mmio.c | 13 +- | ||
137 | target/arm/cpu.c | 23 +- | ||
138 | target/arm/cpu64.c | 5 + | ||
139 | target/arm/cpu_tcg.c | 8 + | ||
140 | target/arm/helper-a64.c | 32 -- | ||
141 | target/arm/helper.c | 39 +- | ||
142 | target/arm/mte_helper.c | 13 +- | ||
143 | target/arm/translate-a64.c | 70 +--- | ||
144 | target/arm/vec_helper.c | 48 +++ | ||
145 | tests/qtest/npcm7xx_emc-test.c | 862 +++++++++++++++++++++++++++++++++++++++ | ||
146 | hw/net/meson.build | 1 + | ||
147 | hw/net/trace-events | 17 + | ||
148 | tests/qtest/meson.build | 3 +- | ||
149 | 49 files changed, 3098 insertions(+), 628 deletions(-) | ||
150 | delete mode 100644 hw/display/omap_lcd_template.h | ||
151 | delete mode 100644 hw/display/tc6393xb_template.h | ||
152 | create mode 100644 include/hw/net/npcm7xx_emc.h | ||
153 | create mode 100644 hw/net/npcm7xx_emc.c | ||
154 | create mode 100644 tests/qtest/npcm7xx_emc-test.c | ||
155 | diff view generated by jsdifflib |
1 | In the mps2-tz board code, we handle devices whose interrupt lines | 1 | Correct a couple of minor errors in the Cortex-A710 definition: |
---|---|---|---|
2 | must be wired to all CPUs by creating IRQ splitter devices for the | 2 | * ID_AA64DFR0_EL1.DebugVer is 9 (indicating Armv8.4 debug architecture) |
3 | AN521, because it has 2 CPUs, but wiring the device IRQ directly to | 3 | * ID_AA64ISAR1_EL1.APA is 5 (indicating more PAuth support) |
4 | the SSE/IoTKit input for the AN505, which has only 1 CPU. | 4 | * there is an IMPDEF CPUCFR_EL1, like that on the Neoverse-N1 |
5 | 5 | ||
6 | We can avoid making an explicit check on the board type constant by | 6 | Fixes: e3d45c0a89576 ("target/arm: Implement cortex-a710") |
7 | instead creating and using the IRQ splitters for any board with more | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | than 1 CPU. This avoids having to add extra cases to the | 8 | Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
9 | conditionals every time we add new boards. | 9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
10 | Message-id: 20230915185453.1871167-2-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/tcg/cpu64.c | 11 +++++++++-- | ||
13 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
10 | 14 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20210215115138.20465-9-peter.maydell@linaro.org | ||
15 | --- | ||
16 | hw/arm/mps2-tz.c | 19 +++++++++---------- | ||
17 | 1 file changed, 9 insertions(+), 10 deletions(-) | ||
18 | |||
19 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/mps2-tz.c | 17 | --- a/target/arm/tcg/cpu64.c |
22 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/target/arm/tcg/cpu64.c |
23 | @@ -XXX,XX +XXX,XX @@ static void make_ram_alias(MemoryRegion *mr, const char *name, | 19 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortex_a710_cp_reginfo[] = { |
24 | static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) | 20 | { .name = "CPUPFR_EL3", .state = ARM_CP_STATE_AA64, |
25 | { | 21 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 6, |
26 | /* Return a qemu_irq which will signal IRQ n to all CPUs in the SSE. */ | 22 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
27 | - MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 23 | + /* |
28 | + MachineClass *mc = MACHINE_GET_CLASS(mms); | 24 | + * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU |
29 | 25 | + * (and in particular its system registers). | |
30 | assert(irqno < MPS2TZ_NUMIRQ); | 26 | + */ |
31 | 27 | + { .name = "CPUCFR_EL1", .state = ARM_CP_STATE_AA64, | |
32 | - switch (mmc->fpga_type) { | 28 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0, |
33 | - case FPGA_AN505: | 29 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 }, |
34 | - return qdev_get_gpio_in_named(DEVICE(&mms->iotkit), "EXP_IRQ", irqno); | ||
35 | - case FPGA_AN521: | ||
36 | + if (mc->max_cpus > 1) { | ||
37 | return qdev_get_gpio_in(DEVICE(&mms->cpu_irq_splitter[irqno]), 0); | ||
38 | - default: | ||
39 | - g_assert_not_reached(); | ||
40 | + } else { | ||
41 | + return qdev_get_gpio_in_named(DEVICE(&mms->iotkit), "EXP_IRQ", irqno); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
46 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); | ||
47 | 30 | ||
48 | /* | 31 | /* |
49 | - * The AN521 needs us to create splitters to feed the IRQ inputs | 32 | * Stub RAMINDEX, as we don't actually implement caches, BTB, |
50 | - * for each CPU in the SSE-200 from each device in the board. | 33 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a710_initfn(Object *obj) |
51 | + * If this board has more than one CPU, then we need to create splitters | 34 | cpu->isar.id_aa64pfr0 = 0x1201111120111112ull; /* GIC filled in later */ |
52 | + * to feed the IRQ inputs for each CPU in the SSE from each device in the | 35 | cpu->isar.id_aa64pfr1 = 0x0000000000000221ull; |
53 | + * board. If there is only one CPU, we can just wire the device IRQ | 36 | cpu->isar.id_aa64zfr0 = 0x0000110100110021ull; /* with Crypto */ |
54 | + * directly to the SSE's IRQ input. | 37 | - cpu->isar.id_aa64dfr0 = 0x000011f010305611ull; |
55 | */ | 38 | + cpu->isar.id_aa64dfr0 = 0x000011f010305619ull; |
56 | - if (mmc->fpga_type == FPGA_AN521) { | 39 | cpu->isar.id_aa64dfr1 = 0; |
57 | + if (mc->max_cpus > 1) { | 40 | cpu->id_aa64afr0 = 0; |
58 | for (i = 0; i < MPS2TZ_NUMIRQ; i++) { | 41 | cpu->id_aa64afr1 = 0; |
59 | char *name = g_strdup_printf("mps2-irq-splitter%d", i); | 42 | cpu->isar.id_aa64isar0 = 0x0221111110212120ull; /* with Crypto */ |
60 | SplitIRQ *splitter = &mms->cpu_irq_splitter[i]; | 43 | - cpu->isar.id_aa64isar1 = 0x0010111101211032ull; |
44 | + cpu->isar.id_aa64isar1 = 0x0010111101211052ull; | ||
45 | cpu->isar.id_aa64mmfr0 = 0x0000022200101122ull; | ||
46 | cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
47 | cpu->isar.id_aa64mmfr2 = 0x1221011110101011ull; | ||
61 | -- | 48 | -- |
62 | 2.20.1 | 49 | 2.34.1 |
63 | 50 | ||
64 | 51 | diff view generated by jsdifflib |
1 | Add support for the mps3-an524 board; this is an SSE-200 based FPGA | 1 | Implement a model of the Neoverse N2 CPU. This is an Armv9.0-A |
---|---|---|---|
2 | image, like the existing mps2-an521. It has a usefully larger amount | 2 | processor very similar to the Cortex-A710. The differences are: |
3 | of RAM, and a PL031 RTC, as well as some more minor differences. | 3 | * no FEAT_EVT |
4 | * FEAT_DGH (data gathering hint) | ||
5 | * FEAT_NV (not yet implemented in QEMU) | ||
6 | * Statistical Profiling Extension (not implemented in QEMU) | ||
7 | * 48 bit physical address range, not 40 | ||
8 | * CTR_EL0.DIC = 1 (no explicit icache cleaning needed) | ||
9 | * PMCR_EL0.N = 6 (always 6 PMU counters, not 20) | ||
4 | 10 | ||
5 | In real hardware this image runs on a newer generation of the FPGA | 11 | Because it has 48-bit physical address support, we can use |
6 | board, the MPS3 rather than the older MPS2. Architecturally the two | 12 | this CPU in the sbsa-ref board as well as the virt board. |
7 | boards are similar, so we implement the MPS3 boards in the mps2-tz.c | ||
8 | file as variations of the existing MPS2 boards. | ||
9 | 13 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
12 | Message-id: 20210215115138.20465-21-peter.maydell@linaro.org | 16 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
17 | Message-id: 20230915185453.1871167-3-peter.maydell@linaro.org | ||
13 | --- | 18 | --- |
14 | hw/arm/mps2-tz.c | 139 +++++++++++++++++++++++++++++++++++++++++++++-- | 19 | docs/system/arm/virt.rst | 1 + |
15 | 1 file changed, 135 insertions(+), 4 deletions(-) | 20 | hw/arm/sbsa-ref.c | 1 + |
21 | hw/arm/virt.c | 1 + | ||
22 | target/arm/tcg/cpu64.c | 103 +++++++++++++++++++++++++++++++++++++++ | ||
23 | 4 files changed, 106 insertions(+) | ||
16 | 24 | ||
17 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 25 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/mps2-tz.c | 27 | --- a/docs/system/arm/virt.rst |
20 | +++ b/hw/arm/mps2-tz.c | 28 | +++ b/docs/system/arm/virt.rst |
21 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: |
22 | * This source file covers the following FPGA images, for TrustZone cores: | 30 | - ``host`` (with KVM only) |
23 | * "mps2-an505" -- Cortex-M33 as documented in ARM Application Note AN505 | 31 | - ``neoverse-n1`` (64-bit) |
24 | * "mps2-an521" -- Dual Cortex-M33 as documented in Application Note AN521 | 32 | - ``neoverse-v1`` (64-bit) |
25 | + * "mps2-an524" -- Dual Cortex-M33 as documented in Application Note AN524 | 33 | +- ``neoverse-n2`` (64-bit) |
26 | * | 34 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) |
27 | * Links to the TRM for the board itself and to the various Application | 35 | |
28 | * Notes which document the FPGA images can be found here: | 36 | Note that the default is ``cortex-a15``, so for an AArch64 guest you must |
29 | @@ -XXX,XX +XXX,XX @@ | 37 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
30 | * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | 38 | index XXXXXXX..XXXXXXX 100644 |
31 | * Application Note AN521: | 39 | --- a/hw/arm/sbsa-ref.c |
32 | * http://infocenter.arm.com/help/topic/com.arm.doc.dai0521c/index.html | 40 | +++ b/hw/arm/sbsa-ref.c |
33 | + * Application Note AN524: | 41 | @@ -XXX,XX +XXX,XX @@ static const char * const valid_cpus[] = { |
34 | + * https://developer.arm.com/documentation/dai0524/latest/ | 42 | ARM_CPU_TYPE_NAME("cortex-a72"), |
35 | * | 43 | ARM_CPU_TYPE_NAME("neoverse-n1"), |
36 | * The AN505 defers to the Cortex-M33 processor ARMv8M IoT Kit FVP User Guide | 44 | ARM_CPU_TYPE_NAME("neoverse-v1"), |
37 | * (ARM ECM0601256) for the details of some of the device layout: | 45 | + ARM_CPU_TYPE_NAME("neoverse-n2"), |
38 | * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | 46 | ARM_CPU_TYPE_NAME("max"), |
39 | - * Similarly, the AN521 uses the SSE-200, and the SSE-200 TRM defines | ||
40 | + * Similarly, the AN521 and AN524 use the SSE-200, and the SSE-200 TRM defines | ||
41 | * most of the device layout: | ||
42 | * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | ||
43 | * | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | #include "hw/qdev-clock.h" | ||
46 | #include "qom/object.h" | ||
47 | |||
48 | -#define MPS2TZ_NUMIRQ_MAX 92 | ||
49 | +#define MPS2TZ_NUMIRQ_MAX 95 | ||
50 | #define MPS2TZ_RAM_MAX 4 | ||
51 | |||
52 | typedef enum MPS2TZFPGAType { | ||
53 | FPGA_AN505, | ||
54 | FPGA_AN521, | ||
55 | + FPGA_AN524, | ||
56 | } MPS2TZFPGAType; | ||
57 | |||
58 | /* | ||
59 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | ||
60 | TZPPC ppc[5]; | ||
61 | TZMPC mpc[3]; | ||
62 | PL022State spi[5]; | ||
63 | - ArmSbconI2CState i2c[4]; | ||
64 | + ArmSbconI2CState i2c[5]; | ||
65 | UnimplementedDeviceState i2s_audio; | ||
66 | UnimplementedDeviceState gpio[4]; | ||
67 | UnimplementedDeviceState gfx; | ||
68 | + UnimplementedDeviceState cldc; | ||
69 | + UnimplementedDeviceState rtc; | ||
70 | PL080State dma[4]; | ||
71 | TZMSC msc[4]; | ||
72 | - CMSDKAPBUART uart[5]; | ||
73 | + CMSDKAPBUART uart[6]; | ||
74 | SplitIRQ sec_resp_splitter; | ||
75 | qemu_or_irq uart_irq_orgate; | ||
76 | DeviceState *lan9118; | ||
77 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | ||
78 | #define TYPE_MPS2TZ_MACHINE "mps2tz" | ||
79 | #define TYPE_MPS2TZ_AN505_MACHINE MACHINE_TYPE_NAME("mps2-an505") | ||
80 | #define TYPE_MPS2TZ_AN521_MACHINE MACHINE_TYPE_NAME("mps2-an521") | ||
81 | +#define TYPE_MPS3TZ_AN524_MACHINE MACHINE_TYPE_NAME("mps3-an524") | ||
82 | |||
83 | OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static const uint32_t an505_oscclk[] = { | ||
86 | 25000000, | ||
87 | }; | 47 | }; |
88 | 48 | ||
89 | +static const uint32_t an524_oscclk[] = { | 49 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
90 | + 24000000, | 50 | index XXXXXXX..XXXXXXX 100644 |
91 | + 32000000, | 51 | --- a/hw/arm/virt.c |
92 | + 50000000, | 52 | +++ b/hw/arm/virt.c |
93 | + 50000000, | 53 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { |
94 | + 24576000, | 54 | ARM_CPU_TYPE_NAME("a64fx"), |
95 | + 23750000, | 55 | ARM_CPU_TYPE_NAME("neoverse-n1"), |
56 | ARM_CPU_TYPE_NAME("neoverse-v1"), | ||
57 | + ARM_CPU_TYPE_NAME("neoverse-n2"), | ||
58 | #endif | ||
59 | ARM_CPU_TYPE_NAME("cortex-a53"), | ||
60 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
61 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/tcg/cpu64.c | ||
64 | +++ b/target/arm/tcg/cpu64.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a710_initfn(Object *obj) | ||
66 | aarch64_add_sve_properties(obj); | ||
67 | } | ||
68 | |||
69 | +/* Extra IMPDEF regs in the N2 beyond those in the A710 */ | ||
70 | +static const ARMCPRegInfo neoverse_n2_cp_reginfo[] = { | ||
71 | + { .name = "CPURNDBR_EL3", .state = ARM_CP_STATE_AA64, | ||
72 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 3, .opc2 = 0, | ||
73 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
74 | + { .name = "CPURNDPEID_EL3", .state = ARM_CP_STATE_AA64, | ||
75 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 3, .opc2 = 1, | ||
76 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
96 | +}; | 77 | +}; |
97 | + | 78 | + |
98 | static const RAMInfo an505_raminfo[] = { { | 79 | +static void aarch64_neoverse_n2_initfn(Object *obj) |
99 | .name = "ssram-0", | 80 | +{ |
100 | .base = 0x00000000, | 81 | + ARMCPU *cpu = ARM_CPU(obj); |
101 | @@ -XXX,XX +XXX,XX @@ static const RAMInfo an505_raminfo[] = { { | ||
102 | }, | ||
103 | }; | ||
104 | |||
105 | +static const RAMInfo an524_raminfo[] = { { | ||
106 | + .name = "bram", | ||
107 | + .base = 0x00000000, | ||
108 | + .size = 512 * KiB, | ||
109 | + .mpc = 0, | ||
110 | + .mrindex = 0, | ||
111 | + }, { | ||
112 | + .name = "sram", | ||
113 | + .base = 0x20000000, | ||
114 | + .size = 32 * 4 * KiB, | ||
115 | + .mpc = 1, | ||
116 | + .mrindex = 1, | ||
117 | + }, { | ||
118 | + /* We don't model QSPI flash yet; for now expose it as simple ROM */ | ||
119 | + .name = "QSPI", | ||
120 | + .base = 0x28000000, | ||
121 | + .size = 8 * MiB, | ||
122 | + .mpc = 1, | ||
123 | + .mrindex = 2, | ||
124 | + .flags = IS_ROM, | ||
125 | + }, { | ||
126 | + .name = "DDR", | ||
127 | + .base = 0x60000000, | ||
128 | + .size = 2 * GiB, | ||
129 | + .mpc = 2, | ||
130 | + .mrindex = -1, | ||
131 | + }, { | ||
132 | + .name = NULL, | ||
133 | + }, | ||
134 | +}; | ||
135 | + | 82 | + |
136 | static const RAMInfo *find_raminfo_for_mpc(MPS2TZMachineState *mms, int mpc) | 83 | + cpu->dtb_compatible = "arm,neoverse-n2"; |
137 | { | 84 | + set_feature(&cpu->env, ARM_FEATURE_V8); |
138 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 85 | + set_feature(&cpu->env, ARM_FEATURE_NEON); |
139 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 86 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
140 | }, | 87 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
141 | }; | 88 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
142 | 89 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | |
143 | + const PPCInfo an524_ppcs[] = { { | 90 | + set_feature(&cpu->env, ARM_FEATURE_EL3); |
144 | + .name = "apb_ppcexp0", | 91 | + set_feature(&cpu->env, ARM_FEATURE_PMU); |
145 | + .ports = { | ||
146 | + { "bram-mpc", make_mpc, &mms->mpc[0], 0x58007000, 0x1000 }, | ||
147 | + { "qspi-mpc", make_mpc, &mms->mpc[1], 0x58008000, 0x1000 }, | ||
148 | + { "ddr-mpc", make_mpc, &mms->mpc[2], 0x58009000, 0x1000 }, | ||
149 | + }, | ||
150 | + }, { | ||
151 | + .name = "apb_ppcexp1", | ||
152 | + .ports = { | ||
153 | + { "i2c0", make_i2c, &mms->i2c[0], 0x41200000, 0x1000 }, | ||
154 | + { "i2c1", make_i2c, &mms->i2c[1], 0x41201000, 0x1000 }, | ||
155 | + { "spi0", make_spi, &mms->spi[0], 0x41202000, 0x1000, { 52 } }, | ||
156 | + { "spi1", make_spi, &mms->spi[1], 0x41203000, 0x1000, { 53 } }, | ||
157 | + { "spi2", make_spi, &mms->spi[2], 0x41204000, 0x1000, { 54 } }, | ||
158 | + { "i2c2", make_i2c, &mms->i2c[2], 0x41205000, 0x1000 }, | ||
159 | + { "i2c3", make_i2c, &mms->i2c[3], 0x41206000, 0x1000 }, | ||
160 | + { /* port 7 reserved */ }, | ||
161 | + { "i2c4", make_i2c, &mms->i2c[4], 0x41208000, 0x1000 }, | ||
162 | + }, | ||
163 | + }, { | ||
164 | + .name = "apb_ppcexp2", | ||
165 | + .ports = { | ||
166 | + { "scc", make_scc, &mms->scc, 0x41300000, 0x1000 }, | ||
167 | + { "i2s-audio", make_unimp_dev, &mms->i2s_audio, | ||
168 | + 0x41301000, 0x1000 }, | ||
169 | + { "fpgaio", make_fpgaio, &mms->fpgaio, 0x41302000, 0x1000 }, | ||
170 | + { "uart0", make_uart, &mms->uart[0], 0x41303000, 0x1000, { 32, 33, 42 } }, | ||
171 | + { "uart1", make_uart, &mms->uart[1], 0x41304000, 0x1000, { 34, 35, 43 } }, | ||
172 | + { "uart2", make_uart, &mms->uart[2], 0x41305000, 0x1000, { 36, 37, 44 } }, | ||
173 | + { "uart3", make_uart, &mms->uart[3], 0x41306000, 0x1000, { 38, 39, 45 } }, | ||
174 | + { "uart4", make_uart, &mms->uart[4], 0x41307000, 0x1000, { 40, 41, 46 } }, | ||
175 | + { "uart5", make_uart, &mms->uart[5], 0x41308000, 0x1000, { 124, 125, 126 } }, | ||
176 | + | 92 | + |
177 | + { /* port 9 reserved */ }, | 93 | + /* Ordered by Section B.5: AArch64 ID registers */ |
178 | + { "clcd", make_unimp_dev, &mms->cldc, 0x4130a000, 0x1000 }, | 94 | + cpu->midr = 0x410FD493; /* r0p3 */ |
179 | + { "rtc", make_unimp_dev, &mms->rtc, 0x4130b000, 0x1000 }, | 95 | + cpu->revidr = 0; |
180 | + }, | 96 | + cpu->isar.id_pfr0 = 0x21110131; |
181 | + }, { | 97 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ |
182 | + .name = "ahb_ppcexp0", | 98 | + cpu->isar.id_dfr0 = 0x16011099; |
183 | + .ports = { | 99 | + cpu->id_afr0 = 0; |
184 | + { "gpio0", make_unimp_dev, &mms->gpio[0], 0x41100000, 0x1000 }, | 100 | + cpu->isar.id_mmfr0 = 0x10201105; |
185 | + { "gpio1", make_unimp_dev, &mms->gpio[1], 0x41101000, 0x1000 }, | 101 | + cpu->isar.id_mmfr1 = 0x40000000; |
186 | + { "gpio2", make_unimp_dev, &mms->gpio[2], 0x41102000, 0x1000 }, | 102 | + cpu->isar.id_mmfr2 = 0x01260000; |
187 | + { "gpio3", make_unimp_dev, &mms->gpio[3], 0x41103000, 0x1000 }, | 103 | + cpu->isar.id_mmfr3 = 0x02122211; |
188 | + { "eth", make_eth_dev, NULL, 0x41400000, 0x100000, { 48 } }, | 104 | + cpu->isar.id_isar0 = 0x02101110; |
189 | + }, | 105 | + cpu->isar.id_isar1 = 0x13112111; |
190 | + }, | 106 | + cpu->isar.id_isar2 = 0x21232042; |
191 | + }; | 107 | + cpu->isar.id_isar3 = 0x01112131; |
108 | + cpu->isar.id_isar4 = 0x00010142; | ||
109 | + cpu->isar.id_isar5 = 0x11011121; /* with Crypto */ | ||
110 | + cpu->isar.id_mmfr4 = 0x01021110; | ||
111 | + cpu->isar.id_isar6 = 0x01111111; | ||
112 | + cpu->isar.mvfr0 = 0x10110222; | ||
113 | + cpu->isar.mvfr1 = 0x13211111; | ||
114 | + cpu->isar.mvfr2 = 0x00000043; | ||
115 | + cpu->isar.id_pfr2 = 0x00000011; | ||
116 | + cpu->isar.id_aa64pfr0 = 0x1201111120111112ull; /* GIC filled in later */ | ||
117 | + cpu->isar.id_aa64pfr1 = 0x0000000000000221ull; | ||
118 | + cpu->isar.id_aa64zfr0 = 0x0000110100110021ull; /* with Crypto */ | ||
119 | + cpu->isar.id_aa64dfr0 = 0x000011f210305619ull; | ||
120 | + cpu->isar.id_aa64dfr1 = 0; | ||
121 | + cpu->id_aa64afr0 = 0; | ||
122 | + cpu->id_aa64afr1 = 0; | ||
123 | + cpu->isar.id_aa64isar0 = 0x0221111110212120ull; /* with Crypto */ | ||
124 | + cpu->isar.id_aa64isar1 = 0x0011111101211052ull; | ||
125 | + cpu->isar.id_aa64mmfr0 = 0x0000022200101125ull; | ||
126 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
127 | + cpu->isar.id_aa64mmfr2 = 0x1221011112101011ull; | ||
128 | + cpu->clidr = 0x0000001482000023ull; | ||
129 | + cpu->gm_blocksize = 4; | ||
130 | + cpu->ctr = 0x00000004b444c004ull; | ||
131 | + cpu->dcz_blocksize = 4; | ||
132 | + /* TODO FEAT_MPAM: mpamidr_el1 = 0x0000_0001_001e_01ff */ | ||
192 | + | 133 | + |
193 | switch (mmc->fpga_type) { | 134 | + /* Section B.7.2: PMCR_EL0 */ |
194 | case FPGA_AN505: | 135 | + cpu->isar.reset_pmcr_el0 = 0x3000; /* with 6 counters */ |
195 | case FPGA_AN521: | ||
196 | ppcs = an505_ppcs; | ||
197 | num_ppcs = ARRAY_SIZE(an505_ppcs); | ||
198 | break; | ||
199 | + case FPGA_AN524: | ||
200 | + ppcs = an524_ppcs; | ||
201 | + num_ppcs = ARRAY_SIZE(an524_ppcs); | ||
202 | + break; | ||
203 | default: | ||
204 | g_assert_not_reached(); | ||
205 | } | ||
206 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
207 | mps2tz_set_default_ram_info(mmc); | ||
208 | } | ||
209 | |||
210 | +static void mps3tz_an524_class_init(ObjectClass *oc, void *data) | ||
211 | +{ | ||
212 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
213 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc); | ||
214 | + | 136 | + |
215 | + mc->desc = "ARM MPS3 with AN524 FPGA image for dual Cortex-M33"; | 137 | + /* Section B.8.9: ICH_VTR_EL2 */ |
216 | + mc->default_cpus = 2; | 138 | + cpu->gic_num_lrs = 4; |
217 | + mc->min_cpus = mc->default_cpus; | 139 | + cpu->gic_vpribits = 5; |
218 | + mc->max_cpus = mc->default_cpus; | 140 | + cpu->gic_vprebits = 5; |
219 | + mmc->fpga_type = FPGA_AN524; | 141 | + cpu->gic_pribits = 5; |
220 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | 142 | + |
221 | + mmc->scc_id = 0x41045240; | 143 | + /* Section 14: Scalable Vector Extensions support */ |
222 | + mmc->sysclk_frq = 32 * 1000 * 1000; /* 32MHz */ | 144 | + cpu->sve_vq.supported = 1 << 0; /* 128bit */ |
223 | + mmc->oscclk = an524_oscclk; | 145 | + |
224 | + mmc->len_oscclk = ARRAY_SIZE(an524_oscclk); | 146 | + /* |
225 | + mmc->fpgaio_num_leds = 10; | 147 | + * The Neoverse N2 TRM does not list CCSIDR values. The layout of |
226 | + mmc->fpgaio_has_switches = true; | 148 | + * the caches are in text in Table 7-1, Table 8-1, and Table 9-1. |
227 | + mmc->numirq = 95; | 149 | + * |
228 | + mmc->raminfo = an524_raminfo; | 150 | + * L1: 4-way set associative 64-byte line size, total 64K. |
229 | + mmc->armsse_type = TYPE_SSE200; | 151 | + * L2: 8-way set associative 64 byte line size, total either 512K or 1024K. |
230 | + mps2tz_set_default_ram_info(mmc); | 152 | + */ |
153 | + cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */ | ||
154 | + cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */ | ||
155 | + cpu->ccsidr[2] = make_ccsidr64(8, 64, 512 * KiB); /* L2 cache */ | ||
156 | + | ||
157 | + /* FIXME: Not documented -- copied from neoverse-v1 */ | ||
158 | + cpu->reset_sctlr = 0x30c50838; | ||
159 | + | ||
160 | + /* | ||
161 | + * The Neoverse N2 has all of the Cortex-A710 IMPDEF registers, | ||
162 | + * and a few more RNG related ones. | ||
163 | + */ | ||
164 | + define_arm_cp_regs(cpu, cortex_a710_cp_reginfo); | ||
165 | + define_arm_cp_regs(cpu, neoverse_n2_cp_reginfo); | ||
166 | + | ||
167 | + aarch64_add_pauth_properties(obj); | ||
168 | + aarch64_add_sve_properties(obj); | ||
231 | +} | 169 | +} |
232 | + | 170 | + |
233 | static const TypeInfo mps2tz_info = { | 171 | /* |
234 | .name = TYPE_MPS2TZ_MACHINE, | 172 | * -cpu max: a CPU with as many features enabled as our emulation supports. |
235 | .parent = TYPE_MACHINE, | 173 | * The version of '-cpu max' for qemu-system-arm is defined in cpu32.c; |
236 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mps2tz_an521_info = { | 174 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { |
237 | .class_init = mps2tz_an521_class_init, | 175 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, |
176 | { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn }, | ||
177 | { .name = "neoverse-v1", .initfn = aarch64_neoverse_v1_initfn }, | ||
178 | + { .name = "neoverse-n2", .initfn = aarch64_neoverse_n2_initfn }, | ||
238 | }; | 179 | }; |
239 | 180 | ||
240 | +static const TypeInfo mps3tz_an524_info = { | 181 | static void aarch64_cpu_register_types(void) |
241 | + .name = TYPE_MPS3TZ_AN524_MACHINE, | ||
242 | + .parent = TYPE_MPS2TZ_MACHINE, | ||
243 | + .class_init = mps3tz_an524_class_init, | ||
244 | +}; | ||
245 | + | ||
246 | static void mps2tz_machine_init(void) | ||
247 | { | ||
248 | type_register_static(&mps2tz_info); | ||
249 | type_register_static(&mps2tz_an505_info); | ||
250 | type_register_static(&mps2tz_an521_info); | ||
251 | + type_register_static(&mps3tz_an524_info); | ||
252 | } | ||
253 | |||
254 | type_init(mps2tz_machine_init); | ||
255 | -- | 182 | -- |
256 | 2.20.1 | 183 | 2.34.1 |
257 | 184 | ||
258 | 185 | diff view generated by jsdifflib |
1 | We only include the template header once, so just inline it into the | 1 | The feature test functions isar_feature_*() now take up nearly |
---|---|---|---|
2 | source file for the device. | 2 | a thousand lines in target/arm/cpu.h. This header file is included |
3 | by a lot of source files, most of which don't need these functions. | ||
4 | Move the feature test functions to their own header file. | ||
3 | 5 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Message-id: 20231024163510.2972081-2-peter.maydell@linaro.org |
7 | Message-id: 20210215103215.4944-9-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | hw/display/omap_lcd_template.h | 154 --------------------------------- | 11 | bsd-user/arm/target_arch.h | 1 + |
10 | hw/display/omap_lcdc.c | 127 ++++++++++++++++++++++++++- | 12 | linux-user/aarch64/target_prctl.h | 2 + |
11 | 2 files changed, 125 insertions(+), 156 deletions(-) | 13 | target/arm/cpu-features.h | 994 ++++++++++++++++++++++++++++++ |
12 | delete mode 100644 hw/display/omap_lcd_template.h | 14 | target/arm/cpu.h | 971 ----------------------------- |
15 | target/arm/internals.h | 1 + | ||
16 | target/arm/tcg/translate.h | 2 +- | ||
17 | hw/arm/armv7m.c | 1 + | ||
18 | hw/intc/armv7m_nvic.c | 1 + | ||
19 | linux-user/aarch64/cpu_loop.c | 1 + | ||
20 | linux-user/aarch64/signal.c | 1 + | ||
21 | linux-user/arm/signal.c | 1 + | ||
22 | linux-user/elfload.c | 4 + | ||
23 | linux-user/mmap.c | 4 + | ||
24 | target/arm/arch_dump.c | 1 + | ||
25 | target/arm/cpu.c | 1 + | ||
26 | target/arm/cpu64.c | 1 + | ||
27 | target/arm/debug_helper.c | 1 + | ||
28 | target/arm/gdbstub.c | 1 + | ||
29 | target/arm/helper.c | 1 + | ||
30 | target/arm/kvm64.c | 1 + | ||
31 | target/arm/machine.c | 1 + | ||
32 | target/arm/ptw.c | 1 + | ||
33 | target/arm/tcg/cpu64.c | 1 + | ||
34 | target/arm/tcg/hflags.c | 1 + | ||
35 | target/arm/tcg/m_helper.c | 1 + | ||
36 | target/arm/tcg/op_helper.c | 1 + | ||
37 | target/arm/tcg/pauth_helper.c | 1 + | ||
38 | target/arm/tcg/tlb_helper.c | 1 + | ||
39 | target/arm/vfp_helper.c | 1 + | ||
40 | 29 files changed, 1028 insertions(+), 972 deletions(-) | ||
41 | create mode 100644 target/arm/cpu-features.h | ||
13 | 42 | ||
14 | diff --git a/hw/display/omap_lcd_template.h b/hw/display/omap_lcd_template.h | 43 | diff --git a/bsd-user/arm/target_arch.h b/bsd-user/arm/target_arch.h |
15 | deleted file mode 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/bsd-user/arm/target_arch.h | ||
46 | +++ b/bsd-user/arm/target_arch.h | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | #define TARGET_ARCH_H | ||
49 | |||
50 | #include "qemu.h" | ||
51 | +#include "target/arm/cpu-features.h" | ||
52 | |||
53 | void target_cpu_set_tls(CPUARMState *env, target_ulong newtls); | ||
54 | target_ulong target_cpu_get_tls(CPUARMState *env); | ||
55 | diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/linux-user/aarch64/target_prctl.h | ||
58 | +++ b/linux-user/aarch64/target_prctl.h | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | #ifndef AARCH64_TARGET_PRCTL_H | ||
61 | #define AARCH64_TARGET_PRCTL_H | ||
62 | |||
63 | +#include "target/arm/cpu-features.h" | ||
64 | + | ||
65 | static abi_long do_prctl_sve_get_vl(CPUArchState *env) | ||
66 | { | ||
67 | ARMCPU *cpu = env_archcpu(env); | ||
68 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h | ||
69 | new file mode 100644 | ||
16 | index XXXXXXX..XXXXXXX | 70 | index XXXXXXX..XXXXXXX |
17 | --- a/hw/display/omap_lcd_template.h | 71 | --- /dev/null |
18 | +++ /dev/null | 72 | +++ b/target/arm/cpu-features.h |
19 | @@ -XXX,XX +XXX,XX @@ | 73 | @@ -XXX,XX +XXX,XX @@ |
74 | +/* | ||
75 | + * QEMU Arm CPU -- feature test functions | ||
76 | + * | ||
77 | + * Copyright (c) 2023 Linaro Ltd | ||
78 | + * | ||
79 | + * This library is free software; you can redistribute it and/or | ||
80 | + * modify it under the terms of the GNU Lesser General Public | ||
81 | + * License as published by the Free Software Foundation; either | ||
82 | + * version 2.1 of the License, or (at your option) any later version. | ||
83 | + * | ||
84 | + * This library is distributed in the hope that it will be useful, | ||
85 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
86 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
87 | + * Lesser General Public License for more details. | ||
88 | + * | ||
89 | + * You should have received a copy of the GNU Lesser General Public | ||
90 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
91 | + */ | ||
92 | + | ||
93 | +#ifndef TARGET_ARM_FEATURES_H | ||
94 | +#define TARGET_ARM_FEATURES_H | ||
95 | + | ||
96 | +/* | ||
97 | + * Naming convention for isar_feature functions: | ||
98 | + * Functions which test 32-bit ID registers should have _aa32_ in | ||
99 | + * their name. Functions which test 64-bit ID registers should have | ||
100 | + * _aa64_ in their name. These must only be used in code where we | ||
101 | + * know for certain that the CPU has AArch32 or AArch64 respectively | ||
102 | + * or where the correct answer for a CPU which doesn't implement that | ||
103 | + * CPU state is "false" (eg when generating A32 or A64 code, if adding | ||
104 | + * system registers that are specific to that CPU state, for "should | ||
105 | + * we let this system register bit be set" tests where the 32-bit | ||
106 | + * flavour of the register doesn't have the bit, and so on). | ||
107 | + * Functions which simply ask "does this feature exist at all" have | ||
108 | + * _any_ in their name, and always return the logical OR of the _aa64_ | ||
109 | + * and the _aa32_ function. | ||
110 | + */ | ||
111 | + | ||
112 | +/* | ||
113 | + * 32-bit feature tests via id registers. | ||
114 | + */ | ||
115 | +static inline bool isar_feature_aa32_thumb_div(const ARMISARegisters *id) | ||
116 | +{ | ||
117 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0; | ||
118 | +} | ||
119 | + | ||
120 | +static inline bool isar_feature_aa32_arm_div(const ARMISARegisters *id) | ||
121 | +{ | ||
122 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; | ||
123 | +} | ||
124 | + | ||
125 | +static inline bool isar_feature_aa32_lob(const ARMISARegisters *id) | ||
126 | +{ | ||
127 | + /* (M-profile) low-overhead loops and branch future */ | ||
128 | + return FIELD_EX32(id->id_isar0, ID_ISAR0, CMPBRANCH) >= 3; | ||
129 | +} | ||
130 | + | ||
131 | +static inline bool isar_feature_aa32_jazelle(const ARMISARegisters *id) | ||
132 | +{ | ||
133 | + return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) != 0; | ||
134 | +} | ||
135 | + | ||
136 | +static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) | ||
137 | +{ | ||
138 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; | ||
139 | +} | ||
140 | + | ||
141 | +static inline bool isar_feature_aa32_pmull(const ARMISARegisters *id) | ||
142 | +{ | ||
143 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) > 1; | ||
144 | +} | ||
145 | + | ||
146 | +static inline bool isar_feature_aa32_sha1(const ARMISARegisters *id) | ||
147 | +{ | ||
148 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA1) != 0; | ||
149 | +} | ||
150 | + | ||
151 | +static inline bool isar_feature_aa32_sha2(const ARMISARegisters *id) | ||
152 | +{ | ||
153 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA2) != 0; | ||
154 | +} | ||
155 | + | ||
156 | +static inline bool isar_feature_aa32_crc32(const ARMISARegisters *id) | ||
157 | +{ | ||
158 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, CRC32) != 0; | ||
159 | +} | ||
160 | + | ||
161 | +static inline bool isar_feature_aa32_rdm(const ARMISARegisters *id) | ||
162 | +{ | ||
163 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, RDM) != 0; | ||
164 | +} | ||
165 | + | ||
166 | +static inline bool isar_feature_aa32_vcma(const ARMISARegisters *id) | ||
167 | +{ | ||
168 | + return FIELD_EX32(id->id_isar5, ID_ISAR5, VCMA) != 0; | ||
169 | +} | ||
170 | + | ||
171 | +static inline bool isar_feature_aa32_jscvt(const ARMISARegisters *id) | ||
172 | +{ | ||
173 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, JSCVT) != 0; | ||
174 | +} | ||
175 | + | ||
176 | +static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) | ||
177 | +{ | ||
178 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; | ||
179 | +} | ||
180 | + | ||
181 | +static inline bool isar_feature_aa32_fhm(const ARMISARegisters *id) | ||
182 | +{ | ||
183 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, FHM) != 0; | ||
184 | +} | ||
185 | + | ||
186 | +static inline bool isar_feature_aa32_sb(const ARMISARegisters *id) | ||
187 | +{ | ||
188 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, SB) != 0; | ||
189 | +} | ||
190 | + | ||
191 | +static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) | ||
192 | +{ | ||
193 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; | ||
194 | +} | ||
195 | + | ||
196 | +static inline bool isar_feature_aa32_bf16(const ARMISARegisters *id) | ||
197 | +{ | ||
198 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, BF16) != 0; | ||
199 | +} | ||
200 | + | ||
201 | +static inline bool isar_feature_aa32_i8mm(const ARMISARegisters *id) | ||
202 | +{ | ||
203 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, I8MM) != 0; | ||
204 | +} | ||
205 | + | ||
206 | +static inline bool isar_feature_aa32_ras(const ARMISARegisters *id) | ||
207 | +{ | ||
208 | + return FIELD_EX32(id->id_pfr0, ID_PFR0, RAS) != 0; | ||
209 | +} | ||
210 | + | ||
211 | +static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) | ||
212 | +{ | ||
213 | + return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; | ||
214 | +} | ||
215 | + | ||
216 | +static inline bool isar_feature_aa32_m_sec_state(const ARMISARegisters *id) | ||
217 | +{ | ||
218 | + /* | ||
219 | + * Return true if M-profile state handling insns | ||
220 | + * (VSCCLRM, CLRM, FPCTX access insns) are implemented | ||
221 | + */ | ||
222 | + return FIELD_EX32(id->id_pfr1, ID_PFR1, SECURITY) >= 3; | ||
223 | +} | ||
224 | + | ||
225 | +static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
226 | +{ | ||
227 | + /* Sadly this is encoded differently for A-profile and M-profile */ | ||
228 | + if (isar_feature_aa32_mprofile(id)) { | ||
229 | + return FIELD_EX32(id->mvfr1, MVFR1, FP16) > 0; | ||
230 | + } else { | ||
231 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3; | ||
232 | + } | ||
233 | +} | ||
234 | + | ||
235 | +static inline bool isar_feature_aa32_mve(const ARMISARegisters *id) | ||
236 | +{ | ||
237 | + /* | ||
238 | + * Return true if MVE is supported (either integer or floating point). | ||
239 | + * We must check for M-profile as the MVFR1 field means something | ||
240 | + * else for A-profile. | ||
241 | + */ | ||
242 | + return isar_feature_aa32_mprofile(id) && | ||
243 | + FIELD_EX32(id->mvfr1, MVFR1, MVE) > 0; | ||
244 | +} | ||
245 | + | ||
246 | +static inline bool isar_feature_aa32_mve_fp(const ARMISARegisters *id) | ||
247 | +{ | ||
248 | + /* | ||
249 | + * Return true if MVE is supported (either integer or floating point). | ||
250 | + * We must check for M-profile as the MVFR1 field means something | ||
251 | + * else for A-profile. | ||
252 | + */ | ||
253 | + return isar_feature_aa32_mprofile(id) && | ||
254 | + FIELD_EX32(id->mvfr1, MVFR1, MVE) >= 2; | ||
255 | +} | ||
256 | + | ||
257 | +static inline bool isar_feature_aa32_vfp_simd(const ARMISARegisters *id) | ||
258 | +{ | ||
259 | + /* | ||
260 | + * Return true if either VFP or SIMD is implemented. | ||
261 | + * In this case, a minimum of VFP w/ D0-D15. | ||
262 | + */ | ||
263 | + return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) > 0; | ||
264 | +} | ||
265 | + | ||
266 | +static inline bool isar_feature_aa32_simd_r32(const ARMISARegisters *id) | ||
267 | +{ | ||
268 | + /* Return true if D16-D31 are implemented */ | ||
269 | + return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) >= 2; | ||
270 | +} | ||
271 | + | ||
272 | +static inline bool isar_feature_aa32_fpshvec(const ARMISARegisters *id) | ||
273 | +{ | ||
274 | + return FIELD_EX32(id->mvfr0, MVFR0, FPSHVEC) > 0; | ||
275 | +} | ||
276 | + | ||
277 | +static inline bool isar_feature_aa32_fpsp_v2(const ARMISARegisters *id) | ||
278 | +{ | ||
279 | + /* Return true if CPU supports single precision floating point, VFPv2 */ | ||
280 | + return FIELD_EX32(id->mvfr0, MVFR0, FPSP) > 0; | ||
281 | +} | ||
282 | + | ||
283 | +static inline bool isar_feature_aa32_fpsp_v3(const ARMISARegisters *id) | ||
284 | +{ | ||
285 | + /* Return true if CPU supports single precision floating point, VFPv3 */ | ||
286 | + return FIELD_EX32(id->mvfr0, MVFR0, FPSP) >= 2; | ||
287 | +} | ||
288 | + | ||
289 | +static inline bool isar_feature_aa32_fpdp_v2(const ARMISARegisters *id) | ||
290 | +{ | ||
291 | + /* Return true if CPU supports double precision floating point, VFPv2 */ | ||
292 | + return FIELD_EX32(id->mvfr0, MVFR0, FPDP) > 0; | ||
293 | +} | ||
294 | + | ||
295 | +static inline bool isar_feature_aa32_fpdp_v3(const ARMISARegisters *id) | ||
296 | +{ | ||
297 | + /* Return true if CPU supports double precision floating point, VFPv3 */ | ||
298 | + return FIELD_EX32(id->mvfr0, MVFR0, FPDP) >= 2; | ||
299 | +} | ||
300 | + | ||
301 | +static inline bool isar_feature_aa32_vfp(const ARMISARegisters *id) | ||
302 | +{ | ||
303 | + return isar_feature_aa32_fpsp_v2(id) || isar_feature_aa32_fpdp_v2(id); | ||
304 | +} | ||
305 | + | ||
306 | +/* | ||
307 | + * We always set the FP and SIMD FP16 fields to indicate identical | ||
308 | + * levels of support (assuming SIMD is implemented at all), so | ||
309 | + * we only need one set of accessors. | ||
310 | + */ | ||
311 | +static inline bool isar_feature_aa32_fp16_spconv(const ARMISARegisters *id) | ||
312 | +{ | ||
313 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) > 0; | ||
314 | +} | ||
315 | + | ||
316 | +static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id) | ||
317 | +{ | ||
318 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) > 1; | ||
319 | +} | ||
320 | + | ||
321 | +/* | ||
322 | + * Note that this ID register field covers both VFP and Neon FMAC, | ||
323 | + * so should usually be tested in combination with some other | ||
324 | + * check that confirms the presence of whichever of VFP or Neon is | ||
325 | + * relevant, to avoid accidentally enabling a Neon feature on | ||
326 | + * a VFP-no-Neon core or vice-versa. | ||
327 | + */ | ||
328 | +static inline bool isar_feature_aa32_simdfmac(const ARMISARegisters *id) | ||
329 | +{ | ||
330 | + return FIELD_EX32(id->mvfr1, MVFR1, SIMDFMAC) != 0; | ||
331 | +} | ||
332 | + | ||
333 | +static inline bool isar_feature_aa32_vsel(const ARMISARegisters *id) | ||
334 | +{ | ||
335 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 1; | ||
336 | +} | ||
337 | + | ||
338 | +static inline bool isar_feature_aa32_vcvt_dr(const ARMISARegisters *id) | ||
339 | +{ | ||
340 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 2; | ||
341 | +} | ||
342 | + | ||
343 | +static inline bool isar_feature_aa32_vrint(const ARMISARegisters *id) | ||
344 | +{ | ||
345 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 3; | ||
346 | +} | ||
347 | + | ||
348 | +static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
349 | +{ | ||
350 | + return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
351 | +} | ||
352 | + | ||
353 | +static inline bool isar_feature_aa32_pxn(const ARMISARegisters *id) | ||
354 | +{ | ||
355 | + return FIELD_EX32(id->id_mmfr0, ID_MMFR0, VMSA) >= 4; | ||
356 | +} | ||
357 | + | ||
358 | +static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) | ||
359 | +{ | ||
360 | + return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) != 0; | ||
361 | +} | ||
362 | + | ||
363 | +static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id) | ||
364 | +{ | ||
365 | + return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) >= 2; | ||
366 | +} | ||
367 | + | ||
368 | +static inline bool isar_feature_aa32_pmuv3p1(const ARMISARegisters *id) | ||
369 | +{ | ||
370 | + /* 0xf means "non-standard IMPDEF PMU" */ | ||
371 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 4 && | ||
372 | + FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
373 | +} | ||
374 | + | ||
375 | +static inline bool isar_feature_aa32_pmuv3p4(const ARMISARegisters *id) | ||
376 | +{ | ||
377 | + /* 0xf means "non-standard IMPDEF PMU" */ | ||
378 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 5 && | ||
379 | + FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
380 | +} | ||
381 | + | ||
382 | +static inline bool isar_feature_aa32_pmuv3p5(const ARMISARegisters *id) | ||
383 | +{ | ||
384 | + /* 0xf means "non-standard IMPDEF PMU" */ | ||
385 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 6 && | ||
386 | + FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
387 | +} | ||
388 | + | ||
389 | +static inline bool isar_feature_aa32_hpd(const ARMISARegisters *id) | ||
390 | +{ | ||
391 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, HPDS) != 0; | ||
392 | +} | ||
393 | + | ||
394 | +static inline bool isar_feature_aa32_ac2(const ARMISARegisters *id) | ||
395 | +{ | ||
396 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, AC2) != 0; | ||
397 | +} | ||
398 | + | ||
399 | +static inline bool isar_feature_aa32_ccidx(const ARMISARegisters *id) | ||
400 | +{ | ||
401 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, CCIDX) != 0; | ||
402 | +} | ||
403 | + | ||
404 | +static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id) | ||
405 | +{ | ||
406 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0; | ||
407 | +} | ||
408 | + | ||
409 | +static inline bool isar_feature_aa32_half_evt(const ARMISARegisters *id) | ||
410 | +{ | ||
411 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 1; | ||
412 | +} | ||
413 | + | ||
414 | +static inline bool isar_feature_aa32_evt(const ARMISARegisters *id) | ||
415 | +{ | ||
416 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 2; | ||
417 | +} | ||
418 | + | ||
419 | +static inline bool isar_feature_aa32_dit(const ARMISARegisters *id) | ||
420 | +{ | ||
421 | + return FIELD_EX32(id->id_pfr0, ID_PFR0, DIT) != 0; | ||
422 | +} | ||
423 | + | ||
424 | +static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) | ||
425 | +{ | ||
426 | + return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; | ||
427 | +} | ||
428 | + | ||
429 | +static inline bool isar_feature_aa32_debugv7p1(const ARMISARegisters *id) | ||
430 | +{ | ||
431 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 5; | ||
432 | +} | ||
433 | + | ||
434 | +static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id) | ||
435 | +{ | ||
436 | + return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8; | ||
437 | +} | ||
438 | + | ||
439 | +static inline bool isar_feature_aa32_doublelock(const ARMISARegisters *id) | ||
440 | +{ | ||
441 | + return FIELD_EX32(id->dbgdevid, DBGDEVID, DOUBLELOCK) > 0; | ||
442 | +} | ||
443 | + | ||
444 | +/* | ||
445 | + * 64-bit feature tests via id registers. | ||
446 | + */ | ||
447 | +static inline bool isar_feature_aa64_aes(const ARMISARegisters *id) | ||
448 | +{ | ||
449 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, AES) != 0; | ||
450 | +} | ||
451 | + | ||
452 | +static inline bool isar_feature_aa64_pmull(const ARMISARegisters *id) | ||
453 | +{ | ||
454 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, AES) > 1; | ||
455 | +} | ||
456 | + | ||
457 | +static inline bool isar_feature_aa64_sha1(const ARMISARegisters *id) | ||
458 | +{ | ||
459 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA1) != 0; | ||
460 | +} | ||
461 | + | ||
462 | +static inline bool isar_feature_aa64_sha256(const ARMISARegisters *id) | ||
463 | +{ | ||
464 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA2) != 0; | ||
465 | +} | ||
466 | + | ||
467 | +static inline bool isar_feature_aa64_sha512(const ARMISARegisters *id) | ||
468 | +{ | ||
469 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA2) > 1; | ||
470 | +} | ||
471 | + | ||
472 | +static inline bool isar_feature_aa64_crc32(const ARMISARegisters *id) | ||
473 | +{ | ||
474 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, CRC32) != 0; | ||
475 | +} | ||
476 | + | ||
477 | +static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id) | ||
478 | +{ | ||
479 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, ATOMIC) != 0; | ||
480 | +} | ||
481 | + | ||
482 | +static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id) | ||
483 | +{ | ||
484 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, RDM) != 0; | ||
485 | +} | ||
486 | + | ||
487 | +static inline bool isar_feature_aa64_sha3(const ARMISARegisters *id) | ||
488 | +{ | ||
489 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA3) != 0; | ||
490 | +} | ||
491 | + | ||
492 | +static inline bool isar_feature_aa64_sm3(const ARMISARegisters *id) | ||
493 | +{ | ||
494 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SM3) != 0; | ||
495 | +} | ||
496 | + | ||
497 | +static inline bool isar_feature_aa64_sm4(const ARMISARegisters *id) | ||
498 | +{ | ||
499 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SM4) != 0; | ||
500 | +} | ||
501 | + | ||
502 | +static inline bool isar_feature_aa64_dp(const ARMISARegisters *id) | ||
503 | +{ | ||
504 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0; | ||
505 | +} | ||
506 | + | ||
507 | +static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id) | ||
508 | +{ | ||
509 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, FHM) != 0; | ||
510 | +} | ||
511 | + | ||
512 | +static inline bool isar_feature_aa64_condm_4(const ARMISARegisters *id) | ||
513 | +{ | ||
514 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) != 0; | ||
515 | +} | ||
516 | + | ||
517 | +static inline bool isar_feature_aa64_condm_5(const ARMISARegisters *id) | ||
518 | +{ | ||
519 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) >= 2; | ||
520 | +} | ||
521 | + | ||
522 | +static inline bool isar_feature_aa64_rndr(const ARMISARegisters *id) | ||
523 | +{ | ||
524 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, RNDR) != 0; | ||
525 | +} | ||
526 | + | ||
527 | +static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) | ||
528 | +{ | ||
529 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; | ||
530 | +} | ||
531 | + | ||
532 | +static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | ||
533 | +{ | ||
534 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | ||
535 | +} | ||
536 | + | ||
537 | +/* | ||
538 | + * These are the values from APA/API/APA3. | ||
539 | + * In general these must be compared '>=', per the normal Arm ARM | ||
540 | + * treatment of fields in ID registers. | ||
541 | + */ | ||
542 | +typedef enum { | ||
543 | + PauthFeat_None = 0, | ||
544 | + PauthFeat_1 = 1, | ||
545 | + PauthFeat_EPAC = 2, | ||
546 | + PauthFeat_2 = 3, | ||
547 | + PauthFeat_FPAC = 4, | ||
548 | + PauthFeat_FPACCOMBINED = 5, | ||
549 | +} ARMPauthFeature; | ||
550 | + | ||
551 | +static inline ARMPauthFeature | ||
552 | +isar_feature_pauth_feature(const ARMISARegisters *id) | ||
553 | +{ | ||
554 | + /* | ||
555 | + * Architecturally, only one of {APA,API,APA3} may be active (non-zero) | ||
556 | + * and the other two must be zero. Thus we may avoid conditionals. | ||
557 | + */ | ||
558 | + return (FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) | | ||
559 | + FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, API) | | ||
560 | + FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3)); | ||
561 | +} | ||
562 | + | ||
563 | +static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) | ||
564 | +{ | ||
565 | + /* | ||
566 | + * Return true if any form of pauth is enabled, as this | ||
567 | + * predicate controls migration of the 128-bit keys. | ||
568 | + */ | ||
569 | + return isar_feature_pauth_feature(id) != PauthFeat_None; | ||
570 | +} | ||
571 | + | ||
572 | +static inline bool isar_feature_aa64_pauth_qarma5(const ARMISARegisters *id) | ||
573 | +{ | ||
574 | + /* | ||
575 | + * Return true if pauth is enabled with the architected QARMA5 algorithm. | ||
576 | + * QEMU will always enable or disable both APA and GPA. | ||
577 | + */ | ||
578 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0; | ||
579 | +} | ||
580 | + | ||
581 | +static inline bool isar_feature_aa64_pauth_qarma3(const ARMISARegisters *id) | ||
582 | +{ | ||
583 | + /* | ||
584 | + * Return true if pauth is enabled with the architected QARMA3 algorithm. | ||
585 | + * QEMU will always enable or disable both APA3 and GPA3. | ||
586 | + */ | ||
587 | + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) != 0; | ||
588 | +} | ||
589 | + | ||
590 | +static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) | ||
591 | +{ | ||
592 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; | ||
593 | +} | ||
594 | + | ||
595 | +static inline bool isar_feature_aa64_tlbios(const ARMISARegisters *id) | ||
596 | +{ | ||
597 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) != 0; | ||
598 | +} | ||
599 | + | ||
600 | +static inline bool isar_feature_aa64_sb(const ARMISARegisters *id) | ||
601 | +{ | ||
602 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0; | ||
603 | +} | ||
604 | + | ||
605 | +static inline bool isar_feature_aa64_predinv(const ARMISARegisters *id) | ||
606 | +{ | ||
607 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SPECRES) != 0; | ||
608 | +} | ||
609 | + | ||
610 | +static inline bool isar_feature_aa64_frint(const ARMISARegisters *id) | ||
611 | +{ | ||
612 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FRINTTS) != 0; | ||
613 | +} | ||
614 | + | ||
615 | +static inline bool isar_feature_aa64_dcpop(const ARMISARegisters *id) | ||
616 | +{ | ||
617 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) != 0; | ||
618 | +} | ||
619 | + | ||
620 | +static inline bool isar_feature_aa64_dcpodp(const ARMISARegisters *id) | ||
621 | +{ | ||
622 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) >= 2; | ||
623 | +} | ||
624 | + | ||
625 | +static inline bool isar_feature_aa64_bf16(const ARMISARegisters *id) | ||
626 | +{ | ||
627 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, BF16) != 0; | ||
628 | +} | ||
629 | + | ||
630 | +static inline bool isar_feature_aa64_fp_simd(const ARMISARegisters *id) | ||
631 | +{ | ||
632 | + /* We always set the AdvSIMD and FP fields identically. */ | ||
633 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) != 0xf; | ||
634 | +} | ||
635 | + | ||
636 | +static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | ||
637 | +{ | ||
638 | + /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
639 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; | ||
640 | +} | ||
641 | + | ||
642 | +static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id) | ||
643 | +{ | ||
644 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2; | ||
645 | +} | ||
646 | + | ||
647 | +static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) | ||
648 | +{ | ||
649 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; | ||
650 | +} | ||
651 | + | ||
652 | +static inline bool isar_feature_aa64_aa32_el2(const ARMISARegisters *id) | ||
653 | +{ | ||
654 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL2) >= 2; | ||
655 | +} | ||
656 | + | ||
657 | +static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) | ||
658 | +{ | ||
659 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; | ||
660 | +} | ||
661 | + | ||
662 | +static inline bool isar_feature_aa64_doublefault(const ARMISARegisters *id) | ||
663 | +{ | ||
664 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) >= 2; | ||
665 | +} | ||
666 | + | ||
667 | +static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) | ||
668 | +{ | ||
669 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; | ||
670 | +} | ||
671 | + | ||
672 | +static inline bool isar_feature_aa64_sel2(const ARMISARegisters *id) | ||
673 | +{ | ||
674 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SEL2) != 0; | ||
675 | +} | ||
676 | + | ||
677 | +static inline bool isar_feature_aa64_rme(const ARMISARegisters *id) | ||
678 | +{ | ||
679 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RME) != 0; | ||
680 | +} | ||
681 | + | ||
682 | +static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) | ||
683 | +{ | ||
684 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; | ||
685 | +} | ||
686 | + | ||
687 | +static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) | ||
688 | +{ | ||
689 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; | ||
690 | +} | ||
691 | + | ||
692 | +static inline bool isar_feature_aa64_pan(const ARMISARegisters *id) | ||
693 | +{ | ||
694 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) != 0; | ||
695 | +} | ||
696 | + | ||
697 | +static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) | ||
698 | +{ | ||
699 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; | ||
700 | +} | ||
701 | + | ||
702 | +static inline bool isar_feature_aa64_pan3(const ARMISARegisters *id) | ||
703 | +{ | ||
704 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 3; | ||
705 | +} | ||
706 | + | ||
707 | +static inline bool isar_feature_aa64_hcx(const ARMISARegisters *id) | ||
708 | +{ | ||
709 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HCX) != 0; | ||
710 | +} | ||
711 | + | ||
712 | +static inline bool isar_feature_aa64_tidcp1(const ARMISARegisters *id) | ||
713 | +{ | ||
714 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR1, TIDCP1) != 0; | ||
715 | +} | ||
716 | + | ||
717 | +static inline bool isar_feature_aa64_uao(const ARMISARegisters *id) | ||
718 | +{ | ||
719 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0; | ||
720 | +} | ||
721 | + | ||
722 | +static inline bool isar_feature_aa64_st(const ARMISARegisters *id) | ||
723 | +{ | ||
724 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, ST) != 0; | ||
725 | +} | ||
726 | + | ||
727 | +static inline bool isar_feature_aa64_lse2(const ARMISARegisters *id) | ||
728 | +{ | ||
729 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, AT) != 0; | ||
730 | +} | ||
731 | + | ||
732 | +static inline bool isar_feature_aa64_fwb(const ARMISARegisters *id) | ||
733 | +{ | ||
734 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, FWB) != 0; | ||
735 | +} | ||
736 | + | ||
737 | +static inline bool isar_feature_aa64_ids(const ARMISARegisters *id) | ||
738 | +{ | ||
739 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, IDS) != 0; | ||
740 | +} | ||
741 | + | ||
742 | +static inline bool isar_feature_aa64_half_evt(const ARMISARegisters *id) | ||
743 | +{ | ||
744 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 1; | ||
745 | +} | ||
746 | + | ||
747 | +static inline bool isar_feature_aa64_evt(const ARMISARegisters *id) | ||
748 | +{ | ||
749 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 2; | ||
750 | +} | ||
751 | + | ||
752 | +static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
753 | +{ | ||
754 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
755 | +} | ||
756 | + | ||
757 | +static inline bool isar_feature_aa64_mte_insn_reg(const ARMISARegisters *id) | ||
758 | +{ | ||
759 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) != 0; | ||
760 | +} | ||
761 | + | ||
762 | +static inline bool isar_feature_aa64_mte(const ARMISARegisters *id) | ||
763 | +{ | ||
764 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) >= 2; | ||
765 | +} | ||
766 | + | ||
767 | +static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) | ||
768 | +{ | ||
769 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0; | ||
770 | +} | ||
771 | + | ||
772 | +static inline bool isar_feature_aa64_pmuv3p1(const ARMISARegisters *id) | ||
773 | +{ | ||
774 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 4 && | ||
775 | + FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
776 | +} | ||
777 | + | ||
778 | +static inline bool isar_feature_aa64_pmuv3p4(const ARMISARegisters *id) | ||
779 | +{ | ||
780 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 5 && | ||
781 | + FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
782 | +} | ||
783 | + | ||
784 | +static inline bool isar_feature_aa64_pmuv3p5(const ARMISARegisters *id) | ||
785 | +{ | ||
786 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 6 && | ||
787 | + FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
788 | +} | ||
789 | + | ||
790 | +static inline bool isar_feature_aa64_rcpc_8_3(const ARMISARegisters *id) | ||
791 | +{ | ||
792 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) != 0; | ||
793 | +} | ||
794 | + | ||
795 | +static inline bool isar_feature_aa64_rcpc_8_4(const ARMISARegisters *id) | ||
796 | +{ | ||
797 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) >= 2; | ||
798 | +} | ||
799 | + | ||
800 | +static inline bool isar_feature_aa64_i8mm(const ARMISARegisters *id) | ||
801 | +{ | ||
802 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, I8MM) != 0; | ||
803 | +} | ||
804 | + | ||
805 | +static inline bool isar_feature_aa64_hbc(const ARMISARegisters *id) | ||
806 | +{ | ||
807 | + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, BC) != 0; | ||
808 | +} | ||
809 | + | ||
810 | +static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) | ||
811 | +{ | ||
812 | + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1; | ||
813 | +} | ||
814 | + | ||
815 | +static inline bool isar_feature_aa64_tgran4_2_lpa2(const ARMISARegisters *id) | ||
816 | +{ | ||
817 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); | ||
818 | + return t >= 3 || (t == 0 && isar_feature_aa64_tgran4_lpa2(id)); | ||
819 | +} | ||
820 | + | ||
821 | +static inline bool isar_feature_aa64_tgran16_lpa2(const ARMISARegisters *id) | ||
822 | +{ | ||
823 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 2; | ||
824 | +} | ||
825 | + | ||
826 | +static inline bool isar_feature_aa64_tgran16_2_lpa2(const ARMISARegisters *id) | ||
827 | +{ | ||
828 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); | ||
829 | + return t >= 3 || (t == 0 && isar_feature_aa64_tgran16_lpa2(id)); | ||
830 | +} | ||
831 | + | ||
832 | +static inline bool isar_feature_aa64_tgran4(const ARMISARegisters *id) | ||
833 | +{ | ||
834 | + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 0; | ||
835 | +} | ||
836 | + | ||
837 | +static inline bool isar_feature_aa64_tgran16(const ARMISARegisters *id) | ||
838 | +{ | ||
839 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 1; | ||
840 | +} | ||
841 | + | ||
842 | +static inline bool isar_feature_aa64_tgran64(const ARMISARegisters *id) | ||
843 | +{ | ||
844 | + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64) >= 0; | ||
845 | +} | ||
846 | + | ||
847 | +static inline bool isar_feature_aa64_tgran4_2(const ARMISARegisters *id) | ||
848 | +{ | ||
849 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); | ||
850 | + return t >= 2 || (t == 0 && isar_feature_aa64_tgran4(id)); | ||
851 | +} | ||
852 | + | ||
853 | +static inline bool isar_feature_aa64_tgran16_2(const ARMISARegisters *id) | ||
854 | +{ | ||
855 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); | ||
856 | + return t >= 2 || (t == 0 && isar_feature_aa64_tgran16(id)); | ||
857 | +} | ||
858 | + | ||
859 | +static inline bool isar_feature_aa64_tgran64_2(const ARMISARegisters *id) | ||
860 | +{ | ||
861 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64_2); | ||
862 | + return t >= 2 || (t == 0 && isar_feature_aa64_tgran64(id)); | ||
863 | +} | ||
864 | + | ||
865 | +static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) | ||
866 | +{ | ||
867 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; | ||
868 | +} | ||
869 | + | ||
870 | +static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) | ||
871 | +{ | ||
872 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0; | ||
873 | +} | ||
874 | + | ||
875 | +static inline bool isar_feature_aa64_lva(const ARMISARegisters *id) | ||
876 | +{ | ||
877 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) != 0; | ||
878 | +} | ||
879 | + | ||
880 | +static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id) | ||
881 | +{ | ||
882 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0; | ||
883 | +} | ||
884 | + | ||
885 | +static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) | ||
886 | +{ | ||
887 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) != 0; | ||
888 | +} | ||
889 | + | ||
890 | +static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) | ||
891 | +{ | ||
892 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >= 2; | ||
893 | +} | ||
894 | + | ||
895 | +static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) | ||
896 | +{ | ||
897 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0; | ||
898 | +} | ||
899 | + | ||
900 | +static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | ||
901 | +{ | ||
902 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; | ||
903 | +} | ||
904 | + | ||
905 | +static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) | ||
906 | +{ | ||
907 | + int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); | ||
908 | + if (key >= 2) { | ||
909 | + return true; /* FEAT_CSV2_2 */ | ||
910 | + } | ||
911 | + if (key == 1) { | ||
912 | + key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
913 | + return key >= 2; /* FEAT_CSV2_1p2 */ | ||
914 | + } | ||
915 | + return false; | ||
916 | +} | ||
917 | + | ||
918 | +static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
919 | +{ | ||
920 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
921 | +} | ||
922 | + | ||
923 | +static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
924 | +{ | ||
925 | + return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; | ||
926 | +} | ||
927 | + | ||
928 | +static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) | ||
929 | +{ | ||
930 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; | ||
931 | +} | ||
932 | + | ||
933 | +static inline bool isar_feature_aa64_sve2_aes(const ARMISARegisters *id) | ||
934 | +{ | ||
935 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, AES) != 0; | ||
936 | +} | ||
937 | + | ||
938 | +static inline bool isar_feature_aa64_sve2_pmull128(const ARMISARegisters *id) | ||
939 | +{ | ||
940 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, AES) >= 2; | ||
941 | +} | ||
942 | + | ||
943 | +static inline bool isar_feature_aa64_sve2_bitperm(const ARMISARegisters *id) | ||
944 | +{ | ||
945 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, BITPERM) != 0; | ||
946 | +} | ||
947 | + | ||
948 | +static inline bool isar_feature_aa64_sve_bf16(const ARMISARegisters *id) | ||
949 | +{ | ||
950 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, BFLOAT16) != 0; | ||
951 | +} | ||
952 | + | ||
953 | +static inline bool isar_feature_aa64_sve2_sha3(const ARMISARegisters *id) | ||
954 | +{ | ||
955 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SHA3) != 0; | ||
956 | +} | ||
957 | + | ||
958 | +static inline bool isar_feature_aa64_sve2_sm4(const ARMISARegisters *id) | ||
959 | +{ | ||
960 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SM4) != 0; | ||
961 | +} | ||
962 | + | ||
963 | +static inline bool isar_feature_aa64_sve_i8mm(const ARMISARegisters *id) | ||
964 | +{ | ||
965 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, I8MM) != 0; | ||
966 | +} | ||
967 | + | ||
968 | +static inline bool isar_feature_aa64_sve_f32mm(const ARMISARegisters *id) | ||
969 | +{ | ||
970 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, F32MM) != 0; | ||
971 | +} | ||
972 | + | ||
973 | +static inline bool isar_feature_aa64_sve_f64mm(const ARMISARegisters *id) | ||
974 | +{ | ||
975 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, F64MM) != 0; | ||
976 | +} | ||
977 | + | ||
978 | +static inline bool isar_feature_aa64_sme_f64f64(const ARMISARegisters *id) | ||
979 | +{ | ||
980 | + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, F64F64); | ||
981 | +} | ||
982 | + | ||
983 | +static inline bool isar_feature_aa64_sme_i16i64(const ARMISARegisters *id) | ||
984 | +{ | ||
985 | + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, I16I64) == 0xf; | ||
986 | +} | ||
987 | + | ||
988 | +static inline bool isar_feature_aa64_sme_fa64(const ARMISARegisters *id) | ||
989 | +{ | ||
990 | + return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, FA64); | ||
991 | +} | ||
992 | + | ||
993 | +static inline bool isar_feature_aa64_doublelock(const ARMISARegisters *id) | ||
994 | +{ | ||
995 | + return FIELD_SEX64(id->id_aa64dfr0, ID_AA64DFR0, DOUBLELOCK) >= 0; | ||
996 | +} | ||
997 | + | ||
998 | +static inline bool isar_feature_aa64_mops(const ARMISARegisters *id) | ||
999 | +{ | ||
1000 | + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, MOPS); | ||
1001 | +} | ||
1002 | + | ||
1003 | +/* | ||
1004 | + * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
1005 | + */ | ||
1006 | +static inline bool isar_feature_any_fp16(const ARMISARegisters *id) | ||
1007 | +{ | ||
1008 | + return isar_feature_aa64_fp16(id) || isar_feature_aa32_fp16_arith(id); | ||
1009 | +} | ||
1010 | + | ||
1011 | +static inline bool isar_feature_any_predinv(const ARMISARegisters *id) | ||
1012 | +{ | ||
1013 | + return isar_feature_aa64_predinv(id) || isar_feature_aa32_predinv(id); | ||
1014 | +} | ||
1015 | + | ||
1016 | +static inline bool isar_feature_any_pmuv3p1(const ARMISARegisters *id) | ||
1017 | +{ | ||
1018 | + return isar_feature_aa64_pmuv3p1(id) || isar_feature_aa32_pmuv3p1(id); | ||
1019 | +} | ||
1020 | + | ||
1021 | +static inline bool isar_feature_any_pmuv3p4(const ARMISARegisters *id) | ||
1022 | +{ | ||
1023 | + return isar_feature_aa64_pmuv3p4(id) || isar_feature_aa32_pmuv3p4(id); | ||
1024 | +} | ||
1025 | + | ||
1026 | +static inline bool isar_feature_any_pmuv3p5(const ARMISARegisters *id) | ||
1027 | +{ | ||
1028 | + return isar_feature_aa64_pmuv3p5(id) || isar_feature_aa32_pmuv3p5(id); | ||
1029 | +} | ||
1030 | + | ||
1031 | +static inline bool isar_feature_any_ccidx(const ARMISARegisters *id) | ||
1032 | +{ | ||
1033 | + return isar_feature_aa64_ccidx(id) || isar_feature_aa32_ccidx(id); | ||
1034 | +} | ||
1035 | + | ||
1036 | +static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) | ||
1037 | +{ | ||
1038 | + return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); | ||
1039 | +} | ||
1040 | + | ||
1041 | +static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) | ||
1042 | +{ | ||
1043 | + return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); | ||
1044 | +} | ||
1045 | + | ||
1046 | +static inline bool isar_feature_any_ras(const ARMISARegisters *id) | ||
1047 | +{ | ||
1048 | + return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); | ||
1049 | +} | ||
1050 | + | ||
1051 | +static inline bool isar_feature_any_half_evt(const ARMISARegisters *id) | ||
1052 | +{ | ||
1053 | + return isar_feature_aa64_half_evt(id) || isar_feature_aa32_half_evt(id); | ||
1054 | +} | ||
1055 | + | ||
1056 | +static inline bool isar_feature_any_evt(const ARMISARegisters *id) | ||
1057 | +{ | ||
1058 | + return isar_feature_aa64_evt(id) || isar_feature_aa32_evt(id); | ||
1059 | +} | ||
1060 | + | ||
1061 | +/* | ||
1062 | + * Forward to the above feature tests given an ARMCPU pointer. | ||
1063 | + */ | ||
1064 | +#define cpu_isar_feature(name, cpu) \ | ||
1065 | + ({ ARMCPU *cpu_ = (cpu); isar_feature_##name(&cpu_->isar); }) | ||
1066 | + | ||
1067 | +#endif | ||
1068 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
1069 | index XXXXXXX..XXXXXXX 100644 | ||
1070 | --- a/target/arm/cpu.h | ||
1071 | +++ b/target/arm/cpu.h | ||
1072 | @@ -XXX,XX +XXX,XX @@ static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x) | ||
1073 | } | ||
1074 | #endif | ||
1075 | |||
20 | -/* | 1076 | -/* |
21 | - * QEMU OMAP LCD Emulator templates | 1077 | - * Naming convention for isar_feature functions: |
22 | - * | 1078 | - * Functions which test 32-bit ID registers should have _aa32_ in |
23 | - * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org> | 1079 | - * their name. Functions which test 64-bit ID registers should have |
24 | - * | 1080 | - * _aa64_ in their name. These must only be used in code where we |
25 | - * Redistribution and use in source and binary forms, with or without | 1081 | - * know for certain that the CPU has AArch32 or AArch64 respectively |
26 | - * modification, are permitted provided that the following conditions | 1082 | - * or where the correct answer for a CPU which doesn't implement that |
27 | - * are met: | 1083 | - * CPU state is "false" (eg when generating A32 or A64 code, if adding |
28 | - * | 1084 | - * system registers that are specific to that CPU state, for "should |
29 | - * 1. Redistributions of source code must retain the above copyright | 1085 | - * we let this system register bit be set" tests where the 32-bit |
30 | - * notice, this list of conditions and the following disclaimer. | 1086 | - * flavour of the register doesn't have the bit, and so on). |
31 | - * 2. Redistributions in binary form must reproduce the above copyright | 1087 | - * Functions which simply ask "does this feature exist at all" have |
32 | - * notice, this list of conditions and the following disclaimer in | 1088 | - * _any_ in their name, and always return the logical OR of the _aa64_ |
33 | - * the documentation and/or other materials provided with the | 1089 | - * and the _aa32_ function. |
34 | - * distribution. | ||
35 | - * | ||
36 | - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' | ||
37 | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
38 | - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
39 | - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR | ||
40 | - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
41 | - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
42 | - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
43 | - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
44 | - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
45 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
46 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
47 | - */ | 1090 | - */ |
48 | - | 1091 | - |
49 | -/* | 1092 | -/* |
50 | - * 2-bit colour | 1093 | - * 32-bit feature tests via id registers. |
51 | - */ | 1094 | - */ |
52 | -static void draw_line2_32(void *opaque, uint8_t *d, const uint8_t *s, | 1095 | -static inline bool isar_feature_aa32_thumb_div(const ARMISARegisters *id) |
53 | - int width, int deststep) | 1096 | -{ |
54 | -{ | 1097 | - return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) != 0; |
55 | - uint16_t *pal = opaque; | 1098 | -} |
56 | - uint8_t v, r, g, b; | 1099 | - |
57 | - | 1100 | -static inline bool isar_feature_aa32_arm_div(const ARMISARegisters *id) |
58 | - do { | 1101 | -{ |
59 | - v = ldub_p((void *) s); | 1102 | - return FIELD_EX32(id->id_isar0, ID_ISAR0, DIVIDE) > 1; |
60 | - r = (pal[v & 3] >> 4) & 0xf0; | 1103 | -} |
61 | - g = pal[v & 3] & 0xf0; | 1104 | - |
62 | - b = (pal[v & 3] << 4) & 0xf0; | 1105 | -static inline bool isar_feature_aa32_lob(const ARMISARegisters *id) |
63 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1106 | -{ |
64 | - d += 4; | 1107 | - /* (M-profile) low-overhead loops and branch future */ |
65 | - v >>= 2; | 1108 | - return FIELD_EX32(id->id_isar0, ID_ISAR0, CMPBRANCH) >= 3; |
66 | - r = (pal[v & 3] >> 4) & 0xf0; | 1109 | -} |
67 | - g = pal[v & 3] & 0xf0; | 1110 | - |
68 | - b = (pal[v & 3] << 4) & 0xf0; | 1111 | -static inline bool isar_feature_aa32_jazelle(const ARMISARegisters *id) |
69 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1112 | -{ |
70 | - d += 4; | 1113 | - return FIELD_EX32(id->id_isar1, ID_ISAR1, JAZELLE) != 0; |
71 | - v >>= 2; | 1114 | -} |
72 | - r = (pal[v & 3] >> 4) & 0xf0; | 1115 | - |
73 | - g = pal[v & 3] & 0xf0; | 1116 | -static inline bool isar_feature_aa32_aes(const ARMISARegisters *id) |
74 | - b = (pal[v & 3] << 4) & 0xf0; | 1117 | -{ |
75 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1118 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) != 0; |
76 | - d += 4; | 1119 | -} |
77 | - v >>= 2; | 1120 | - |
78 | - r = (pal[v & 3] >> 4) & 0xf0; | 1121 | -static inline bool isar_feature_aa32_pmull(const ARMISARegisters *id) |
79 | - g = pal[v & 3] & 0xf0; | 1122 | -{ |
80 | - b = (pal[v & 3] << 4) & 0xf0; | 1123 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, AES) > 1; |
81 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1124 | -} |
82 | - d += 4; | 1125 | - |
83 | - s++; | 1126 | -static inline bool isar_feature_aa32_sha1(const ARMISARegisters *id) |
84 | - width -= 4; | 1127 | -{ |
85 | - } while (width > 0); | 1128 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA1) != 0; |
1129 | -} | ||
1130 | - | ||
1131 | -static inline bool isar_feature_aa32_sha2(const ARMISARegisters *id) | ||
1132 | -{ | ||
1133 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, SHA2) != 0; | ||
1134 | -} | ||
1135 | - | ||
1136 | -static inline bool isar_feature_aa32_crc32(const ARMISARegisters *id) | ||
1137 | -{ | ||
1138 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, CRC32) != 0; | ||
1139 | -} | ||
1140 | - | ||
1141 | -static inline bool isar_feature_aa32_rdm(const ARMISARegisters *id) | ||
1142 | -{ | ||
1143 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, RDM) != 0; | ||
1144 | -} | ||
1145 | - | ||
1146 | -static inline bool isar_feature_aa32_vcma(const ARMISARegisters *id) | ||
1147 | -{ | ||
1148 | - return FIELD_EX32(id->id_isar5, ID_ISAR5, VCMA) != 0; | ||
1149 | -} | ||
1150 | - | ||
1151 | -static inline bool isar_feature_aa32_jscvt(const ARMISARegisters *id) | ||
1152 | -{ | ||
1153 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, JSCVT) != 0; | ||
1154 | -} | ||
1155 | - | ||
1156 | -static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) | ||
1157 | -{ | ||
1158 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; | ||
1159 | -} | ||
1160 | - | ||
1161 | -static inline bool isar_feature_aa32_fhm(const ARMISARegisters *id) | ||
1162 | -{ | ||
1163 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, FHM) != 0; | ||
1164 | -} | ||
1165 | - | ||
1166 | -static inline bool isar_feature_aa32_sb(const ARMISARegisters *id) | ||
1167 | -{ | ||
1168 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, SB) != 0; | ||
1169 | -} | ||
1170 | - | ||
1171 | -static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) | ||
1172 | -{ | ||
1173 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; | ||
1174 | -} | ||
1175 | - | ||
1176 | -static inline bool isar_feature_aa32_bf16(const ARMISARegisters *id) | ||
1177 | -{ | ||
1178 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, BF16) != 0; | ||
1179 | -} | ||
1180 | - | ||
1181 | -static inline bool isar_feature_aa32_i8mm(const ARMISARegisters *id) | ||
1182 | -{ | ||
1183 | - return FIELD_EX32(id->id_isar6, ID_ISAR6, I8MM) != 0; | ||
1184 | -} | ||
1185 | - | ||
1186 | -static inline bool isar_feature_aa32_ras(const ARMISARegisters *id) | ||
1187 | -{ | ||
1188 | - return FIELD_EX32(id->id_pfr0, ID_PFR0, RAS) != 0; | ||
1189 | -} | ||
1190 | - | ||
1191 | -static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) | ||
1192 | -{ | ||
1193 | - return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; | ||
1194 | -} | ||
1195 | - | ||
1196 | -static inline bool isar_feature_aa32_m_sec_state(const ARMISARegisters *id) | ||
1197 | -{ | ||
1198 | - /* | ||
1199 | - * Return true if M-profile state handling insns | ||
1200 | - * (VSCCLRM, CLRM, FPCTX access insns) are implemented | ||
1201 | - */ | ||
1202 | - return FIELD_EX32(id->id_pfr1, ID_PFR1, SECURITY) >= 3; | ||
1203 | -} | ||
1204 | - | ||
1205 | -static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
1206 | -{ | ||
1207 | - /* Sadly this is encoded differently for A-profile and M-profile */ | ||
1208 | - if (isar_feature_aa32_mprofile(id)) { | ||
1209 | - return FIELD_EX32(id->mvfr1, MVFR1, FP16) > 0; | ||
1210 | - } else { | ||
1211 | - return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3; | ||
1212 | - } | ||
1213 | -} | ||
1214 | - | ||
1215 | -static inline bool isar_feature_aa32_mve(const ARMISARegisters *id) | ||
1216 | -{ | ||
1217 | - /* | ||
1218 | - * Return true if MVE is supported (either integer or floating point). | ||
1219 | - * We must check for M-profile as the MVFR1 field means something | ||
1220 | - * else for A-profile. | ||
1221 | - */ | ||
1222 | - return isar_feature_aa32_mprofile(id) && | ||
1223 | - FIELD_EX32(id->mvfr1, MVFR1, MVE) > 0; | ||
1224 | -} | ||
1225 | - | ||
1226 | -static inline bool isar_feature_aa32_mve_fp(const ARMISARegisters *id) | ||
1227 | -{ | ||
1228 | - /* | ||
1229 | - * Return true if MVE is supported (either integer or floating point). | ||
1230 | - * We must check for M-profile as the MVFR1 field means something | ||
1231 | - * else for A-profile. | ||
1232 | - */ | ||
1233 | - return isar_feature_aa32_mprofile(id) && | ||
1234 | - FIELD_EX32(id->mvfr1, MVFR1, MVE) >= 2; | ||
1235 | -} | ||
1236 | - | ||
1237 | -static inline bool isar_feature_aa32_vfp_simd(const ARMISARegisters *id) | ||
1238 | -{ | ||
1239 | - /* | ||
1240 | - * Return true if either VFP or SIMD is implemented. | ||
1241 | - * In this case, a minimum of VFP w/ D0-D15. | ||
1242 | - */ | ||
1243 | - return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) > 0; | ||
1244 | -} | ||
1245 | - | ||
1246 | -static inline bool isar_feature_aa32_simd_r32(const ARMISARegisters *id) | ||
1247 | -{ | ||
1248 | - /* Return true if D16-D31 are implemented */ | ||
1249 | - return FIELD_EX32(id->mvfr0, MVFR0, SIMDREG) >= 2; | ||
1250 | -} | ||
1251 | - | ||
1252 | -static inline bool isar_feature_aa32_fpshvec(const ARMISARegisters *id) | ||
1253 | -{ | ||
1254 | - return FIELD_EX32(id->mvfr0, MVFR0, FPSHVEC) > 0; | ||
1255 | -} | ||
1256 | - | ||
1257 | -static inline bool isar_feature_aa32_fpsp_v2(const ARMISARegisters *id) | ||
1258 | -{ | ||
1259 | - /* Return true if CPU supports single precision floating point, VFPv2 */ | ||
1260 | - return FIELD_EX32(id->mvfr0, MVFR0, FPSP) > 0; | ||
1261 | -} | ||
1262 | - | ||
1263 | -static inline bool isar_feature_aa32_fpsp_v3(const ARMISARegisters *id) | ||
1264 | -{ | ||
1265 | - /* Return true if CPU supports single precision floating point, VFPv3 */ | ||
1266 | - return FIELD_EX32(id->mvfr0, MVFR0, FPSP) >= 2; | ||
1267 | -} | ||
1268 | - | ||
1269 | -static inline bool isar_feature_aa32_fpdp_v2(const ARMISARegisters *id) | ||
1270 | -{ | ||
1271 | - /* Return true if CPU supports double precision floating point, VFPv2 */ | ||
1272 | - return FIELD_EX32(id->mvfr0, MVFR0, FPDP) > 0; | ||
1273 | -} | ||
1274 | - | ||
1275 | -static inline bool isar_feature_aa32_fpdp_v3(const ARMISARegisters *id) | ||
1276 | -{ | ||
1277 | - /* Return true if CPU supports double precision floating point, VFPv3 */ | ||
1278 | - return FIELD_EX32(id->mvfr0, MVFR0, FPDP) >= 2; | ||
1279 | -} | ||
1280 | - | ||
1281 | -static inline bool isar_feature_aa32_vfp(const ARMISARegisters *id) | ||
1282 | -{ | ||
1283 | - return isar_feature_aa32_fpsp_v2(id) || isar_feature_aa32_fpdp_v2(id); | ||
86 | -} | 1284 | -} |
87 | - | 1285 | - |
88 | -/* | 1286 | -/* |
89 | - * 4-bit colour | 1287 | - * We always set the FP and SIMD FP16 fields to indicate identical |
1288 | - * levels of support (assuming SIMD is implemented at all), so | ||
1289 | - * we only need one set of accessors. | ||
90 | - */ | 1290 | - */ |
91 | -static void draw_line4_32(void *opaque, uint8_t *d, const uint8_t *s, | 1291 | -static inline bool isar_feature_aa32_fp16_spconv(const ARMISARegisters *id) |
92 | - int width, int deststep) | 1292 | -{ |
93 | -{ | 1293 | - return FIELD_EX32(id->mvfr1, MVFR1, FPHP) > 0; |
94 | - uint16_t *pal = opaque; | 1294 | -} |
95 | - uint8_t v, r, g, b; | 1295 | - |
96 | - | 1296 | -static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id) |
97 | - do { | 1297 | -{ |
98 | - v = ldub_p((void *) s); | 1298 | - return FIELD_EX32(id->mvfr1, MVFR1, FPHP) > 1; |
99 | - r = (pal[v & 0xf] >> 4) & 0xf0; | ||
100 | - g = pal[v & 0xf] & 0xf0; | ||
101 | - b = (pal[v & 0xf] << 4) & 0xf0; | ||
102 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
103 | - d += 4; | ||
104 | - v >>= 4; | ||
105 | - r = (pal[v & 0xf] >> 4) & 0xf0; | ||
106 | - g = pal[v & 0xf] & 0xf0; | ||
107 | - b = (pal[v & 0xf] << 4) & 0xf0; | ||
108 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
109 | - d += 4; | ||
110 | - s++; | ||
111 | - width -= 2; | ||
112 | - } while (width > 0); | ||
113 | -} | 1299 | -} |
114 | - | 1300 | - |
115 | -/* | 1301 | -/* |
116 | - * 8-bit colour | 1302 | - * Note that this ID register field covers both VFP and Neon FMAC, |
1303 | - * so should usually be tested in combination with some other | ||
1304 | - * check that confirms the presence of whichever of VFP or Neon is | ||
1305 | - * relevant, to avoid accidentally enabling a Neon feature on | ||
1306 | - * a VFP-no-Neon core or vice-versa. | ||
117 | - */ | 1307 | - */ |
118 | -static void draw_line8_32(void *opaque, uint8_t *d, const uint8_t *s, | 1308 | -static inline bool isar_feature_aa32_simdfmac(const ARMISARegisters *id) |
119 | - int width, int deststep) | 1309 | -{ |
120 | -{ | 1310 | - return FIELD_EX32(id->mvfr1, MVFR1, SIMDFMAC) != 0; |
121 | - uint16_t *pal = opaque; | 1311 | -} |
122 | - uint8_t v, r, g, b; | 1312 | - |
123 | - | 1313 | -static inline bool isar_feature_aa32_vsel(const ARMISARegisters *id) |
124 | - do { | 1314 | -{ |
125 | - v = ldub_p((void *) s); | 1315 | - return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 1; |
126 | - r = (pal[v] >> 4) & 0xf0; | 1316 | -} |
127 | - g = pal[v] & 0xf0; | 1317 | - |
128 | - b = (pal[v] << 4) & 0xf0; | 1318 | -static inline bool isar_feature_aa32_vcvt_dr(const ARMISARegisters *id) |
129 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1319 | -{ |
130 | - s++; | 1320 | - return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 2; |
131 | - d += 4; | 1321 | -} |
132 | - } while (-- width != 0); | 1322 | - |
1323 | -static inline bool isar_feature_aa32_vrint(const ARMISARegisters *id) | ||
1324 | -{ | ||
1325 | - return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 3; | ||
1326 | -} | ||
1327 | - | ||
1328 | -static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
1329 | -{ | ||
1330 | - return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
1331 | -} | ||
1332 | - | ||
1333 | -static inline bool isar_feature_aa32_pxn(const ARMISARegisters *id) | ||
1334 | -{ | ||
1335 | - return FIELD_EX32(id->id_mmfr0, ID_MMFR0, VMSA) >= 4; | ||
1336 | -} | ||
1337 | - | ||
1338 | -static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) | ||
1339 | -{ | ||
1340 | - return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) != 0; | ||
1341 | -} | ||
1342 | - | ||
1343 | -static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id) | ||
1344 | -{ | ||
1345 | - return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) >= 2; | ||
1346 | -} | ||
1347 | - | ||
1348 | -static inline bool isar_feature_aa32_pmuv3p1(const ARMISARegisters *id) | ||
1349 | -{ | ||
1350 | - /* 0xf means "non-standard IMPDEF PMU" */ | ||
1351 | - return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 4 && | ||
1352 | - FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
1353 | -} | ||
1354 | - | ||
1355 | -static inline bool isar_feature_aa32_pmuv3p4(const ARMISARegisters *id) | ||
1356 | -{ | ||
1357 | - /* 0xf means "non-standard IMPDEF PMU" */ | ||
1358 | - return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 5 && | ||
1359 | - FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
1360 | -} | ||
1361 | - | ||
1362 | -static inline bool isar_feature_aa32_pmuv3p5(const ARMISARegisters *id) | ||
1363 | -{ | ||
1364 | - /* 0xf means "non-standard IMPDEF PMU" */ | ||
1365 | - return FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) >= 6 && | ||
1366 | - FIELD_EX32(id->id_dfr0, ID_DFR0, PERFMON) != 0xf; | ||
1367 | -} | ||
1368 | - | ||
1369 | -static inline bool isar_feature_aa32_hpd(const ARMISARegisters *id) | ||
1370 | -{ | ||
1371 | - return FIELD_EX32(id->id_mmfr4, ID_MMFR4, HPDS) != 0; | ||
1372 | -} | ||
1373 | - | ||
1374 | -static inline bool isar_feature_aa32_ac2(const ARMISARegisters *id) | ||
1375 | -{ | ||
1376 | - return FIELD_EX32(id->id_mmfr4, ID_MMFR4, AC2) != 0; | ||
1377 | -} | ||
1378 | - | ||
1379 | -static inline bool isar_feature_aa32_ccidx(const ARMISARegisters *id) | ||
1380 | -{ | ||
1381 | - return FIELD_EX32(id->id_mmfr4, ID_MMFR4, CCIDX) != 0; | ||
1382 | -} | ||
1383 | - | ||
1384 | -static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id) | ||
1385 | -{ | ||
1386 | - return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0; | ||
1387 | -} | ||
1388 | - | ||
1389 | -static inline bool isar_feature_aa32_half_evt(const ARMISARegisters *id) | ||
1390 | -{ | ||
1391 | - return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 1; | ||
1392 | -} | ||
1393 | - | ||
1394 | -static inline bool isar_feature_aa32_evt(const ARMISARegisters *id) | ||
1395 | -{ | ||
1396 | - return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 2; | ||
1397 | -} | ||
1398 | - | ||
1399 | -static inline bool isar_feature_aa32_dit(const ARMISARegisters *id) | ||
1400 | -{ | ||
1401 | - return FIELD_EX32(id->id_pfr0, ID_PFR0, DIT) != 0; | ||
1402 | -} | ||
1403 | - | ||
1404 | -static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) | ||
1405 | -{ | ||
1406 | - return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; | ||
1407 | -} | ||
1408 | - | ||
1409 | -static inline bool isar_feature_aa32_debugv7p1(const ARMISARegisters *id) | ||
1410 | -{ | ||
1411 | - return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 5; | ||
1412 | -} | ||
1413 | - | ||
1414 | -static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id) | ||
1415 | -{ | ||
1416 | - return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8; | ||
1417 | -} | ||
1418 | - | ||
1419 | -static inline bool isar_feature_aa32_doublelock(const ARMISARegisters *id) | ||
1420 | -{ | ||
1421 | - return FIELD_EX32(id->dbgdevid, DBGDEVID, DOUBLELOCK) > 0; | ||
133 | -} | 1422 | -} |
134 | - | 1423 | - |
135 | -/* | 1424 | -/* |
136 | - * 12-bit colour | 1425 | - * 64-bit feature tests via id registers. |
137 | - */ | 1426 | - */ |
138 | -static void draw_line12_32(void *opaque, uint8_t *d, const uint8_t *s, | 1427 | -static inline bool isar_feature_aa64_aes(const ARMISARegisters *id) |
139 | - int width, int deststep) | 1428 | -{ |
140 | -{ | 1429 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, AES) != 0; |
141 | - uint16_t v; | 1430 | -} |
142 | - uint8_t r, g, b; | 1431 | - |
143 | - | 1432 | -static inline bool isar_feature_aa64_pmull(const ARMISARegisters *id) |
144 | - do { | 1433 | -{ |
145 | - v = lduw_le_p((void *) s); | 1434 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, AES) > 1; |
146 | - r = (v >> 4) & 0xf0; | 1435 | -} |
147 | - g = v & 0xf0; | 1436 | - |
148 | - b = (v << 4) & 0xf0; | 1437 | -static inline bool isar_feature_aa64_sha1(const ARMISARegisters *id) |
149 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1438 | -{ |
150 | - s += 2; | 1439 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA1) != 0; |
151 | - d += 4; | 1440 | -} |
152 | - } while (-- width != 0); | 1441 | - |
1442 | -static inline bool isar_feature_aa64_sha256(const ARMISARegisters *id) | ||
1443 | -{ | ||
1444 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA2) != 0; | ||
1445 | -} | ||
1446 | - | ||
1447 | -static inline bool isar_feature_aa64_sha512(const ARMISARegisters *id) | ||
1448 | -{ | ||
1449 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA2) > 1; | ||
1450 | -} | ||
1451 | - | ||
1452 | -static inline bool isar_feature_aa64_crc32(const ARMISARegisters *id) | ||
1453 | -{ | ||
1454 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, CRC32) != 0; | ||
1455 | -} | ||
1456 | - | ||
1457 | -static inline bool isar_feature_aa64_atomics(const ARMISARegisters *id) | ||
1458 | -{ | ||
1459 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, ATOMIC) != 0; | ||
1460 | -} | ||
1461 | - | ||
1462 | -static inline bool isar_feature_aa64_rdm(const ARMISARegisters *id) | ||
1463 | -{ | ||
1464 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, RDM) != 0; | ||
1465 | -} | ||
1466 | - | ||
1467 | -static inline bool isar_feature_aa64_sha3(const ARMISARegisters *id) | ||
1468 | -{ | ||
1469 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SHA3) != 0; | ||
1470 | -} | ||
1471 | - | ||
1472 | -static inline bool isar_feature_aa64_sm3(const ARMISARegisters *id) | ||
1473 | -{ | ||
1474 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SM3) != 0; | ||
1475 | -} | ||
1476 | - | ||
1477 | -static inline bool isar_feature_aa64_sm4(const ARMISARegisters *id) | ||
1478 | -{ | ||
1479 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, SM4) != 0; | ||
1480 | -} | ||
1481 | - | ||
1482 | -static inline bool isar_feature_aa64_dp(const ARMISARegisters *id) | ||
1483 | -{ | ||
1484 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0; | ||
1485 | -} | ||
1486 | - | ||
1487 | -static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id) | ||
1488 | -{ | ||
1489 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, FHM) != 0; | ||
1490 | -} | ||
1491 | - | ||
1492 | -static inline bool isar_feature_aa64_condm_4(const ARMISARegisters *id) | ||
1493 | -{ | ||
1494 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) != 0; | ||
1495 | -} | ||
1496 | - | ||
1497 | -static inline bool isar_feature_aa64_condm_5(const ARMISARegisters *id) | ||
1498 | -{ | ||
1499 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) >= 2; | ||
1500 | -} | ||
1501 | - | ||
1502 | -static inline bool isar_feature_aa64_rndr(const ARMISARegisters *id) | ||
1503 | -{ | ||
1504 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, RNDR) != 0; | ||
1505 | -} | ||
1506 | - | ||
1507 | -static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) | ||
1508 | -{ | ||
1509 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; | ||
1510 | -} | ||
1511 | - | ||
1512 | -static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) | ||
1513 | -{ | ||
1514 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; | ||
153 | -} | 1515 | -} |
154 | - | 1516 | - |
155 | -/* | 1517 | -/* |
156 | - * 16-bit colour | 1518 | - * These are the values from APA/API/APA3. |
1519 | - * In general these must be compared '>=', per the normal Arm ARM | ||
1520 | - * treatment of fields in ID registers. | ||
157 | - */ | 1521 | - */ |
158 | -static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, | 1522 | -typedef enum { |
159 | - int width, int deststep) | 1523 | - PauthFeat_None = 0, |
160 | -{ | 1524 | - PauthFeat_1 = 1, |
161 | - uint16_t v; | 1525 | - PauthFeat_EPAC = 2, |
162 | - uint8_t r, g, b; | 1526 | - PauthFeat_2 = 3, |
163 | - | 1527 | - PauthFeat_FPAC = 4, |
164 | - do { | 1528 | - PauthFeat_FPACCOMBINED = 5, |
165 | - v = lduw_le_p((void *) s); | 1529 | -} ARMPauthFeature; |
166 | - r = (v >> 8) & 0xf8; | 1530 | - |
167 | - g = (v >> 3) & 0xfc; | 1531 | -static inline ARMPauthFeature |
168 | - b = (v << 3) & 0xf8; | 1532 | -isar_feature_pauth_feature(const ARMISARegisters *id) |
169 | - ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1533 | -{ |
170 | - s += 2; | 1534 | - /* |
171 | - d += 4; | 1535 | - * Architecturally, only one of {APA,API,APA3} may be active (non-zero) |
172 | - } while (-- width != 0); | 1536 | - * and the other two must be zero. Thus we may avoid conditionals. |
173 | -} | 1537 | - */ |
174 | diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c | 1538 | - return (FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) | |
175 | index XXXXXXX..XXXXXXX 100644 | 1539 | - FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, API) | |
176 | --- a/hw/display/omap_lcdc.c | 1540 | - FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3)); |
177 | +++ b/hw/display/omap_lcdc.c | 1541 | -} |
178 | @@ -XXX,XX +XXX,XX @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) | 1542 | - |
179 | 1543 | -static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) | |
180 | #define draw_line_func drawfn | 1544 | -{ |
181 | 1545 | - /* | |
182 | -#define DEPTH 32 | 1546 | - * Return true if any form of pauth is enabled, as this |
183 | -#include "omap_lcd_template.h" | 1547 | - * predicate controls migration of the 128-bit keys. |
184 | +/* | 1548 | - */ |
185 | + * 2-bit colour | 1549 | - return isar_feature_pauth_feature(id) != PauthFeat_None; |
186 | + */ | 1550 | -} |
187 | +static void draw_line2_32(void *opaque, uint8_t *d, const uint8_t *s, | 1551 | - |
188 | + int width, int deststep) | 1552 | -static inline bool isar_feature_aa64_pauth_qarma5(const ARMISARegisters *id) |
189 | +{ | 1553 | -{ |
190 | + uint16_t *pal = opaque; | 1554 | - /* |
191 | + uint8_t v, r, g, b; | 1555 | - * Return true if pauth is enabled with the architected QARMA5 algorithm. |
192 | + | 1556 | - * QEMU will always enable or disable both APA and GPA. |
193 | + do { | 1557 | - */ |
194 | + v = ldub_p((void *) s); | 1558 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0; |
195 | + r = (pal[v & 3] >> 4) & 0xf0; | 1559 | -} |
196 | + g = pal[v & 3] & 0xf0; | 1560 | - |
197 | + b = (pal[v & 3] << 4) & 0xf0; | 1561 | -static inline bool isar_feature_aa64_pauth_qarma3(const ARMISARegisters *id) |
198 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1562 | -{ |
199 | + d += 4; | 1563 | - /* |
200 | + v >>= 2; | 1564 | - * Return true if pauth is enabled with the architected QARMA3 algorithm. |
201 | + r = (pal[v & 3] >> 4) & 0xf0; | 1565 | - * QEMU will always enable or disable both APA3 and GPA3. |
202 | + g = pal[v & 3] & 0xf0; | 1566 | - */ |
203 | + b = (pal[v & 3] << 4) & 0xf0; | 1567 | - return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) != 0; |
204 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1568 | -} |
205 | + d += 4; | 1569 | - |
206 | + v >>= 2; | 1570 | -static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) |
207 | + r = (pal[v & 3] >> 4) & 0xf0; | 1571 | -{ |
208 | + g = pal[v & 3] & 0xf0; | 1572 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; |
209 | + b = (pal[v & 3] << 4) & 0xf0; | 1573 | -} |
210 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1574 | - |
211 | + d += 4; | 1575 | -static inline bool isar_feature_aa64_tlbios(const ARMISARegisters *id) |
212 | + v >>= 2; | 1576 | -{ |
213 | + r = (pal[v & 3] >> 4) & 0xf0; | 1577 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) != 0; |
214 | + g = pal[v & 3] & 0xf0; | 1578 | -} |
215 | + b = (pal[v & 3] << 4) & 0xf0; | 1579 | - |
216 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1580 | -static inline bool isar_feature_aa64_sb(const ARMISARegisters *id) |
217 | + d += 4; | 1581 | -{ |
218 | + s++; | 1582 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0; |
219 | + width -= 4; | 1583 | -} |
220 | + } while (width > 0); | 1584 | - |
221 | +} | 1585 | -static inline bool isar_feature_aa64_predinv(const ARMISARegisters *id) |
222 | + | 1586 | -{ |
223 | +/* | 1587 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SPECRES) != 0; |
224 | + * 4-bit colour | 1588 | -} |
225 | + */ | 1589 | - |
226 | +static void draw_line4_32(void *opaque, uint8_t *d, const uint8_t *s, | 1590 | -static inline bool isar_feature_aa64_frint(const ARMISARegisters *id) |
227 | + int width, int deststep) | 1591 | -{ |
228 | +{ | 1592 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FRINTTS) != 0; |
229 | + uint16_t *pal = opaque; | 1593 | -} |
230 | + uint8_t v, r, g, b; | 1594 | - |
231 | + | 1595 | -static inline bool isar_feature_aa64_dcpop(const ARMISARegisters *id) |
232 | + do { | 1596 | -{ |
233 | + v = ldub_p((void *) s); | 1597 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) != 0; |
234 | + r = (pal[v & 0xf] >> 4) & 0xf0; | 1598 | -} |
235 | + g = pal[v & 0xf] & 0xf0; | 1599 | - |
236 | + b = (pal[v & 0xf] << 4) & 0xf0; | 1600 | -static inline bool isar_feature_aa64_dcpodp(const ARMISARegisters *id) |
237 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1601 | -{ |
238 | + d += 4; | 1602 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) >= 2; |
239 | + v >>= 4; | 1603 | -} |
240 | + r = (pal[v & 0xf] >> 4) & 0xf0; | 1604 | - |
241 | + g = pal[v & 0xf] & 0xf0; | 1605 | -static inline bool isar_feature_aa64_bf16(const ARMISARegisters *id) |
242 | + b = (pal[v & 0xf] << 4) & 0xf0; | 1606 | -{ |
243 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1607 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, BF16) != 0; |
244 | + d += 4; | 1608 | -} |
245 | + s++; | 1609 | - |
246 | + width -= 2; | 1610 | -static inline bool isar_feature_aa64_fp_simd(const ARMISARegisters *id) |
247 | + } while (width > 0); | 1611 | -{ |
248 | +} | 1612 | - /* We always set the AdvSIMD and FP fields identically. */ |
249 | + | 1613 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) != 0xf; |
250 | +/* | 1614 | -} |
251 | + * 8-bit colour | 1615 | - |
252 | + */ | 1616 | -static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) |
253 | +static void draw_line8_32(void *opaque, uint8_t *d, const uint8_t *s, | 1617 | -{ |
254 | + int width, int deststep) | 1618 | - /* We always set the AdvSIMD and FP fields identically wrt FP16. */ |
255 | +{ | 1619 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1; |
256 | + uint16_t *pal = opaque; | 1620 | -} |
257 | + uint8_t v, r, g, b; | 1621 | - |
258 | + | 1622 | -static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id) |
259 | + do { | 1623 | -{ |
260 | + v = ldub_p((void *) s); | 1624 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2; |
261 | + r = (pal[v] >> 4) & 0xf0; | 1625 | -} |
262 | + g = pal[v] & 0xf0; | 1626 | - |
263 | + b = (pal[v] << 4) & 0xf0; | 1627 | -static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id) |
264 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1628 | -{ |
265 | + s++; | 1629 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2; |
266 | + d += 4; | 1630 | -} |
267 | + } while (-- width != 0); | 1631 | - |
268 | +} | 1632 | -static inline bool isar_feature_aa64_aa32_el2(const ARMISARegisters *id) |
269 | + | 1633 | -{ |
270 | +/* | 1634 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL2) >= 2; |
271 | + * 12-bit colour | 1635 | -} |
272 | + */ | 1636 | - |
273 | +static void draw_line12_32(void *opaque, uint8_t *d, const uint8_t *s, | 1637 | -static inline bool isar_feature_aa64_ras(const ARMISARegisters *id) |
274 | + int width, int deststep) | 1638 | -{ |
275 | +{ | 1639 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0; |
276 | + uint16_t v; | 1640 | -} |
277 | + uint8_t r, g, b; | 1641 | - |
278 | + | 1642 | -static inline bool isar_feature_aa64_doublefault(const ARMISARegisters *id) |
279 | + do { | 1643 | -{ |
280 | + v = lduw_le_p((void *) s); | 1644 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) >= 2; |
281 | + r = (v >> 4) & 0xf0; | 1645 | -} |
282 | + g = v & 0xf0; | 1646 | - |
283 | + b = (v << 4) & 0xf0; | 1647 | -static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) |
284 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1648 | -{ |
285 | + s += 2; | 1649 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; |
286 | + d += 4; | 1650 | -} |
287 | + } while (-- width != 0); | 1651 | - |
288 | +} | 1652 | -static inline bool isar_feature_aa64_sel2(const ARMISARegisters *id) |
289 | + | 1653 | -{ |
290 | +/* | 1654 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SEL2) != 0; |
291 | + * 16-bit colour | 1655 | -} |
292 | + */ | 1656 | - |
293 | +static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, | 1657 | -static inline bool isar_feature_aa64_rme(const ARMISARegisters *id) |
294 | + int width, int deststep) | 1658 | -{ |
295 | +{ | 1659 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RME) != 0; |
296 | + uint16_t v; | 1660 | -} |
297 | + uint8_t r, g, b; | 1661 | - |
298 | + | 1662 | -static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
299 | + do { | 1663 | -{ |
300 | + v = lduw_le_p((void *) s); | 1664 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; |
301 | + r = (v >> 8) & 0xf8; | 1665 | -} |
302 | + g = (v >> 3) & 0xfc; | 1666 | - |
303 | + b = (v << 3) & 0xf8; | 1667 | -static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) |
304 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | 1668 | -{ |
305 | + s += 2; | 1669 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; |
306 | + d += 4; | 1670 | -} |
307 | + } while (-- width != 0); | 1671 | - |
308 | +} | 1672 | -static inline bool isar_feature_aa64_pan(const ARMISARegisters *id) |
309 | 1673 | -{ | |
310 | static void omap_update_display(void *opaque) | 1674 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) != 0; |
311 | { | 1675 | -} |
1676 | - | ||
1677 | -static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) | ||
1678 | -{ | ||
1679 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; | ||
1680 | -} | ||
1681 | - | ||
1682 | -static inline bool isar_feature_aa64_pan3(const ARMISARegisters *id) | ||
1683 | -{ | ||
1684 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 3; | ||
1685 | -} | ||
1686 | - | ||
1687 | -static inline bool isar_feature_aa64_hcx(const ARMISARegisters *id) | ||
1688 | -{ | ||
1689 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HCX) != 0; | ||
1690 | -} | ||
1691 | - | ||
1692 | -static inline bool isar_feature_aa64_tidcp1(const ARMISARegisters *id) | ||
1693 | -{ | ||
1694 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR1, TIDCP1) != 0; | ||
1695 | -} | ||
1696 | - | ||
1697 | -static inline bool isar_feature_aa64_uao(const ARMISARegisters *id) | ||
1698 | -{ | ||
1699 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0; | ||
1700 | -} | ||
1701 | - | ||
1702 | -static inline bool isar_feature_aa64_st(const ARMISARegisters *id) | ||
1703 | -{ | ||
1704 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, ST) != 0; | ||
1705 | -} | ||
1706 | - | ||
1707 | -static inline bool isar_feature_aa64_lse2(const ARMISARegisters *id) | ||
1708 | -{ | ||
1709 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, AT) != 0; | ||
1710 | -} | ||
1711 | - | ||
1712 | -static inline bool isar_feature_aa64_fwb(const ARMISARegisters *id) | ||
1713 | -{ | ||
1714 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, FWB) != 0; | ||
1715 | -} | ||
1716 | - | ||
1717 | -static inline bool isar_feature_aa64_ids(const ARMISARegisters *id) | ||
1718 | -{ | ||
1719 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, IDS) != 0; | ||
1720 | -} | ||
1721 | - | ||
1722 | -static inline bool isar_feature_aa64_half_evt(const ARMISARegisters *id) | ||
1723 | -{ | ||
1724 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 1; | ||
1725 | -} | ||
1726 | - | ||
1727 | -static inline bool isar_feature_aa64_evt(const ARMISARegisters *id) | ||
1728 | -{ | ||
1729 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 2; | ||
1730 | -} | ||
1731 | - | ||
1732 | -static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
1733 | -{ | ||
1734 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
1735 | -} | ||
1736 | - | ||
1737 | -static inline bool isar_feature_aa64_mte_insn_reg(const ARMISARegisters *id) | ||
1738 | -{ | ||
1739 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) != 0; | ||
1740 | -} | ||
1741 | - | ||
1742 | -static inline bool isar_feature_aa64_mte(const ARMISARegisters *id) | ||
1743 | -{ | ||
1744 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) >= 2; | ||
1745 | -} | ||
1746 | - | ||
1747 | -static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) | ||
1748 | -{ | ||
1749 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0; | ||
1750 | -} | ||
1751 | - | ||
1752 | -static inline bool isar_feature_aa64_pmuv3p1(const ARMISARegisters *id) | ||
1753 | -{ | ||
1754 | - return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 4 && | ||
1755 | - FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
1756 | -} | ||
1757 | - | ||
1758 | -static inline bool isar_feature_aa64_pmuv3p4(const ARMISARegisters *id) | ||
1759 | -{ | ||
1760 | - return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 5 && | ||
1761 | - FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
1762 | -} | ||
1763 | - | ||
1764 | -static inline bool isar_feature_aa64_pmuv3p5(const ARMISARegisters *id) | ||
1765 | -{ | ||
1766 | - return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 6 && | ||
1767 | - FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; | ||
1768 | -} | ||
1769 | - | ||
1770 | -static inline bool isar_feature_aa64_rcpc_8_3(const ARMISARegisters *id) | ||
1771 | -{ | ||
1772 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) != 0; | ||
1773 | -} | ||
1774 | - | ||
1775 | -static inline bool isar_feature_aa64_rcpc_8_4(const ARMISARegisters *id) | ||
1776 | -{ | ||
1777 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) >= 2; | ||
1778 | -} | ||
1779 | - | ||
1780 | -static inline bool isar_feature_aa64_i8mm(const ARMISARegisters *id) | ||
1781 | -{ | ||
1782 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, I8MM) != 0; | ||
1783 | -} | ||
1784 | - | ||
1785 | -static inline bool isar_feature_aa64_hbc(const ARMISARegisters *id) | ||
1786 | -{ | ||
1787 | - return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, BC) != 0; | ||
1788 | -} | ||
1789 | - | ||
1790 | -static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) | ||
1791 | -{ | ||
1792 | - return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1; | ||
1793 | -} | ||
1794 | - | ||
1795 | -static inline bool isar_feature_aa64_tgran4_2_lpa2(const ARMISARegisters *id) | ||
1796 | -{ | ||
1797 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); | ||
1798 | - return t >= 3 || (t == 0 && isar_feature_aa64_tgran4_lpa2(id)); | ||
1799 | -} | ||
1800 | - | ||
1801 | -static inline bool isar_feature_aa64_tgran16_lpa2(const ARMISARegisters *id) | ||
1802 | -{ | ||
1803 | - return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 2; | ||
1804 | -} | ||
1805 | - | ||
1806 | -static inline bool isar_feature_aa64_tgran16_2_lpa2(const ARMISARegisters *id) | ||
1807 | -{ | ||
1808 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); | ||
1809 | - return t >= 3 || (t == 0 && isar_feature_aa64_tgran16_lpa2(id)); | ||
1810 | -} | ||
1811 | - | ||
1812 | -static inline bool isar_feature_aa64_tgran4(const ARMISARegisters *id) | ||
1813 | -{ | ||
1814 | - return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 0; | ||
1815 | -} | ||
1816 | - | ||
1817 | -static inline bool isar_feature_aa64_tgran16(const ARMISARegisters *id) | ||
1818 | -{ | ||
1819 | - return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 1; | ||
1820 | -} | ||
1821 | - | ||
1822 | -static inline bool isar_feature_aa64_tgran64(const ARMISARegisters *id) | ||
1823 | -{ | ||
1824 | - return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64) >= 0; | ||
1825 | -} | ||
1826 | - | ||
1827 | -static inline bool isar_feature_aa64_tgran4_2(const ARMISARegisters *id) | ||
1828 | -{ | ||
1829 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); | ||
1830 | - return t >= 2 || (t == 0 && isar_feature_aa64_tgran4(id)); | ||
1831 | -} | ||
1832 | - | ||
1833 | -static inline bool isar_feature_aa64_tgran16_2(const ARMISARegisters *id) | ||
1834 | -{ | ||
1835 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); | ||
1836 | - return t >= 2 || (t == 0 && isar_feature_aa64_tgran16(id)); | ||
1837 | -} | ||
1838 | - | ||
1839 | -static inline bool isar_feature_aa64_tgran64_2(const ARMISARegisters *id) | ||
1840 | -{ | ||
1841 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64_2); | ||
1842 | - return t >= 2 || (t == 0 && isar_feature_aa64_tgran64(id)); | ||
1843 | -} | ||
1844 | - | ||
1845 | -static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) | ||
1846 | -{ | ||
1847 | - return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; | ||
1848 | -} | ||
1849 | - | ||
1850 | -static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) | ||
1851 | -{ | ||
1852 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0; | ||
1853 | -} | ||
1854 | - | ||
1855 | -static inline bool isar_feature_aa64_lva(const ARMISARegisters *id) | ||
1856 | -{ | ||
1857 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) != 0; | ||
1858 | -} | ||
1859 | - | ||
1860 | -static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id) | ||
1861 | -{ | ||
1862 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0; | ||
1863 | -} | ||
1864 | - | ||
1865 | -static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) | ||
1866 | -{ | ||
1867 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) != 0; | ||
1868 | -} | ||
1869 | - | ||
1870 | -static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) | ||
1871 | -{ | ||
1872 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >= 2; | ||
1873 | -} | ||
1874 | - | ||
1875 | -static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) | ||
1876 | -{ | ||
1877 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0; | ||
1878 | -} | ||
1879 | - | ||
1880 | -static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | ||
1881 | -{ | ||
1882 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; | ||
1883 | -} | ||
1884 | - | ||
1885 | -static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) | ||
1886 | -{ | ||
1887 | - int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); | ||
1888 | - if (key >= 2) { | ||
1889 | - return true; /* FEAT_CSV2_2 */ | ||
1890 | - } | ||
1891 | - if (key == 1) { | ||
1892 | - key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
1893 | - return key >= 2; /* FEAT_CSV2_1p2 */ | ||
1894 | - } | ||
1895 | - return false; | ||
1896 | -} | ||
1897 | - | ||
1898 | -static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
1899 | -{ | ||
1900 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
1901 | -} | ||
1902 | - | ||
1903 | -static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
1904 | -{ | ||
1905 | - return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; | ||
1906 | -} | ||
1907 | - | ||
1908 | -static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) | ||
1909 | -{ | ||
1910 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; | ||
1911 | -} | ||
1912 | - | ||
1913 | -static inline bool isar_feature_aa64_sve2_aes(const ARMISARegisters *id) | ||
1914 | -{ | ||
1915 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, AES) != 0; | ||
1916 | -} | ||
1917 | - | ||
1918 | -static inline bool isar_feature_aa64_sve2_pmull128(const ARMISARegisters *id) | ||
1919 | -{ | ||
1920 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, AES) >= 2; | ||
1921 | -} | ||
1922 | - | ||
1923 | -static inline bool isar_feature_aa64_sve2_bitperm(const ARMISARegisters *id) | ||
1924 | -{ | ||
1925 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, BITPERM) != 0; | ||
1926 | -} | ||
1927 | - | ||
1928 | -static inline bool isar_feature_aa64_sve_bf16(const ARMISARegisters *id) | ||
1929 | -{ | ||
1930 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, BFLOAT16) != 0; | ||
1931 | -} | ||
1932 | - | ||
1933 | -static inline bool isar_feature_aa64_sve2_sha3(const ARMISARegisters *id) | ||
1934 | -{ | ||
1935 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SHA3) != 0; | ||
1936 | -} | ||
1937 | - | ||
1938 | -static inline bool isar_feature_aa64_sve2_sm4(const ARMISARegisters *id) | ||
1939 | -{ | ||
1940 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SM4) != 0; | ||
1941 | -} | ||
1942 | - | ||
1943 | -static inline bool isar_feature_aa64_sve_i8mm(const ARMISARegisters *id) | ||
1944 | -{ | ||
1945 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, I8MM) != 0; | ||
1946 | -} | ||
1947 | - | ||
1948 | -static inline bool isar_feature_aa64_sve_f32mm(const ARMISARegisters *id) | ||
1949 | -{ | ||
1950 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, F32MM) != 0; | ||
1951 | -} | ||
1952 | - | ||
1953 | -static inline bool isar_feature_aa64_sve_f64mm(const ARMISARegisters *id) | ||
1954 | -{ | ||
1955 | - return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, F64MM) != 0; | ||
1956 | -} | ||
1957 | - | ||
1958 | -static inline bool isar_feature_aa64_sme_f64f64(const ARMISARegisters *id) | ||
1959 | -{ | ||
1960 | - return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, F64F64); | ||
1961 | -} | ||
1962 | - | ||
1963 | -static inline bool isar_feature_aa64_sme_i16i64(const ARMISARegisters *id) | ||
1964 | -{ | ||
1965 | - return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, I16I64) == 0xf; | ||
1966 | -} | ||
1967 | - | ||
1968 | -static inline bool isar_feature_aa64_sme_fa64(const ARMISARegisters *id) | ||
1969 | -{ | ||
1970 | - return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, FA64); | ||
1971 | -} | ||
1972 | - | ||
1973 | -static inline bool isar_feature_aa64_doublelock(const ARMISARegisters *id) | ||
1974 | -{ | ||
1975 | - return FIELD_SEX64(id->id_aa64dfr0, ID_AA64DFR0, DOUBLELOCK) >= 0; | ||
1976 | -} | ||
1977 | - | ||
1978 | -static inline bool isar_feature_aa64_mops(const ARMISARegisters *id) | ||
1979 | -{ | ||
1980 | - return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, MOPS); | ||
1981 | -} | ||
1982 | - | ||
1983 | -/* | ||
1984 | - * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
1985 | - */ | ||
1986 | -static inline bool isar_feature_any_fp16(const ARMISARegisters *id) | ||
1987 | -{ | ||
1988 | - return isar_feature_aa64_fp16(id) || isar_feature_aa32_fp16_arith(id); | ||
1989 | -} | ||
1990 | - | ||
1991 | -static inline bool isar_feature_any_predinv(const ARMISARegisters *id) | ||
1992 | -{ | ||
1993 | - return isar_feature_aa64_predinv(id) || isar_feature_aa32_predinv(id); | ||
1994 | -} | ||
1995 | - | ||
1996 | -static inline bool isar_feature_any_pmuv3p1(const ARMISARegisters *id) | ||
1997 | -{ | ||
1998 | - return isar_feature_aa64_pmuv3p1(id) || isar_feature_aa32_pmuv3p1(id); | ||
1999 | -} | ||
2000 | - | ||
2001 | -static inline bool isar_feature_any_pmuv3p4(const ARMISARegisters *id) | ||
2002 | -{ | ||
2003 | - return isar_feature_aa64_pmuv3p4(id) || isar_feature_aa32_pmuv3p4(id); | ||
2004 | -} | ||
2005 | - | ||
2006 | -static inline bool isar_feature_any_pmuv3p5(const ARMISARegisters *id) | ||
2007 | -{ | ||
2008 | - return isar_feature_aa64_pmuv3p5(id) || isar_feature_aa32_pmuv3p5(id); | ||
2009 | -} | ||
2010 | - | ||
2011 | -static inline bool isar_feature_any_ccidx(const ARMISARegisters *id) | ||
2012 | -{ | ||
2013 | - return isar_feature_aa64_ccidx(id) || isar_feature_aa32_ccidx(id); | ||
2014 | -} | ||
2015 | - | ||
2016 | -static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) | ||
2017 | -{ | ||
2018 | - return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); | ||
2019 | -} | ||
2020 | - | ||
2021 | -static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id) | ||
2022 | -{ | ||
2023 | - return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id); | ||
2024 | -} | ||
2025 | - | ||
2026 | -static inline bool isar_feature_any_ras(const ARMISARegisters *id) | ||
2027 | -{ | ||
2028 | - return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); | ||
2029 | -} | ||
2030 | - | ||
2031 | -static inline bool isar_feature_any_half_evt(const ARMISARegisters *id) | ||
2032 | -{ | ||
2033 | - return isar_feature_aa64_half_evt(id) || isar_feature_aa32_half_evt(id); | ||
2034 | -} | ||
2035 | - | ||
2036 | -static inline bool isar_feature_any_evt(const ARMISARegisters *id) | ||
2037 | -{ | ||
2038 | - return isar_feature_aa64_evt(id) || isar_feature_aa32_evt(id); | ||
2039 | -} | ||
2040 | - | ||
2041 | -/* | ||
2042 | - * Forward to the above feature tests given an ARMCPU pointer. | ||
2043 | - */ | ||
2044 | -#define cpu_isar_feature(name, cpu) \ | ||
2045 | - ({ ARMCPU *cpu_ = (cpu); isar_feature_##name(&cpu_->isar); }) | ||
2046 | - | ||
2047 | #endif | ||
2048 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
2049 | index XXXXXXX..XXXXXXX 100644 | ||
2050 | --- a/target/arm/internals.h | ||
2051 | +++ b/target/arm/internals.h | ||
2052 | @@ -XXX,XX +XXX,XX @@ | ||
2053 | #include "hw/registerfields.h" | ||
2054 | #include "tcg/tcg-gvec-desc.h" | ||
2055 | #include "syndrome.h" | ||
2056 | +#include "cpu-features.h" | ||
2057 | |||
2058 | /* register banks for CPU modes */ | ||
2059 | #define BANK_USRSYS 0 | ||
2060 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | ||
2061 | index XXXXXXX..XXXXXXX 100644 | ||
2062 | --- a/target/arm/tcg/translate.h | ||
2063 | +++ b/target/arm/tcg/translate.h | ||
2064 | @@ -XXX,XX +XXX,XX @@ | ||
2065 | #include "exec/translator.h" | ||
2066 | #include "exec/helper-gen.h" | ||
2067 | #include "internals.h" | ||
2068 | - | ||
2069 | +#include "cpu-features.h" | ||
2070 | |||
2071 | /* internal defines */ | ||
2072 | |||
2073 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
2074 | index XXXXXXX..XXXXXXX 100644 | ||
2075 | --- a/hw/arm/armv7m.c | ||
2076 | +++ b/hw/arm/armv7m.c | ||
2077 | @@ -XXX,XX +XXX,XX @@ | ||
2078 | #include "qemu/module.h" | ||
2079 | #include "qemu/log.h" | ||
2080 | #include "target/arm/idau.h" | ||
2081 | +#include "target/arm/cpu-features.h" | ||
2082 | #include "migration/vmstate.h" | ||
2083 | |||
2084 | /* Bitbanded IO. Each word corresponds to a single bit. */ | ||
2085 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
2086 | index XXXXXXX..XXXXXXX 100644 | ||
2087 | --- a/hw/intc/armv7m_nvic.c | ||
2088 | +++ b/hw/intc/armv7m_nvic.c | ||
2089 | @@ -XXX,XX +XXX,XX @@ | ||
2090 | #include "sysemu/tcg.h" | ||
2091 | #include "sysemu/runstate.h" | ||
2092 | #include "target/arm/cpu.h" | ||
2093 | +#include "target/arm/cpu-features.h" | ||
2094 | #include "exec/exec-all.h" | ||
2095 | #include "exec/memop.h" | ||
2096 | #include "qemu/log.h" | ||
2097 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | ||
2098 | index XXXXXXX..XXXXXXX 100644 | ||
2099 | --- a/linux-user/aarch64/cpu_loop.c | ||
2100 | +++ b/linux-user/aarch64/cpu_loop.c | ||
2101 | @@ -XXX,XX +XXX,XX @@ | ||
2102 | #include "qemu/guest-random.h" | ||
2103 | #include "semihosting/common-semi.h" | ||
2104 | #include "target/arm/syndrome.h" | ||
2105 | +#include "target/arm/cpu-features.h" | ||
2106 | |||
2107 | #define get_user_code_u32(x, gaddr, env) \ | ||
2108 | ({ abi_long __r = get_user_u32((x), (gaddr)); \ | ||
2109 | diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c | ||
2110 | index XXXXXXX..XXXXXXX 100644 | ||
2111 | --- a/linux-user/aarch64/signal.c | ||
2112 | +++ b/linux-user/aarch64/signal.c | ||
2113 | @@ -XXX,XX +XXX,XX @@ | ||
2114 | #include "user-internals.h" | ||
2115 | #include "signal-common.h" | ||
2116 | #include "linux-user/trace.h" | ||
2117 | +#include "target/arm/cpu-features.h" | ||
2118 | |||
2119 | struct target_sigcontext { | ||
2120 | uint64_t fault_address; | ||
2121 | diff --git a/linux-user/arm/signal.c b/linux-user/arm/signal.c | ||
2122 | index XXXXXXX..XXXXXXX 100644 | ||
2123 | --- a/linux-user/arm/signal.c | ||
2124 | +++ b/linux-user/arm/signal.c | ||
2125 | @@ -XXX,XX +XXX,XX @@ | ||
2126 | #include "user-internals.h" | ||
2127 | #include "signal-common.h" | ||
2128 | #include "linux-user/trace.h" | ||
2129 | +#include "target/arm/cpu-features.h" | ||
2130 | |||
2131 | struct target_sigcontext { | ||
2132 | abi_ulong trap_no; | ||
2133 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
2134 | index XXXXXXX..XXXXXXX 100644 | ||
2135 | --- a/linux-user/elfload.c | ||
2136 | +++ b/linux-user/elfload.c | ||
2137 | @@ -XXX,XX +XXX,XX @@ | ||
2138 | #include "target_signal.h" | ||
2139 | #include "accel/tcg/debuginfo.h" | ||
2140 | |||
2141 | +#ifdef TARGET_ARM | ||
2142 | +#include "target/arm/cpu-features.h" | ||
2143 | +#endif | ||
2144 | + | ||
2145 | #ifdef _ARCH_PPC64 | ||
2146 | #undef ARCH_DLINFO | ||
2147 | #undef ELF_PLATFORM | ||
2148 | diff --git a/linux-user/mmap.c b/linux-user/mmap.c | ||
2149 | index XXXXXXX..XXXXXXX 100644 | ||
2150 | --- a/linux-user/mmap.c | ||
2151 | +++ b/linux-user/mmap.c | ||
2152 | @@ -XXX,XX +XXX,XX @@ | ||
2153 | #include "target_mman.h" | ||
2154 | #include "qemu/interval-tree.h" | ||
2155 | |||
2156 | +#ifdef TARGET_ARM | ||
2157 | +#include "target/arm/cpu-features.h" | ||
2158 | +#endif | ||
2159 | + | ||
2160 | static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
2161 | static __thread int mmap_lock_count; | ||
2162 | |||
2163 | diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c | ||
2164 | index XXXXXXX..XXXXXXX 100644 | ||
2165 | --- a/target/arm/arch_dump.c | ||
2166 | +++ b/target/arm/arch_dump.c | ||
2167 | @@ -XXX,XX +XXX,XX @@ | ||
2168 | #include "cpu.h" | ||
2169 | #include "elf.h" | ||
2170 | #include "sysemu/dump.h" | ||
2171 | +#include "cpu-features.h" | ||
2172 | |||
2173 | /* struct user_pt_regs from arch/arm64/include/uapi/asm/ptrace.h */ | ||
2174 | struct aarch64_user_regs { | ||
2175 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
2176 | index XXXXXXX..XXXXXXX 100644 | ||
2177 | --- a/target/arm/cpu.c | ||
2178 | +++ b/target/arm/cpu.c | ||
2179 | @@ -XXX,XX +XXX,XX @@ | ||
2180 | #include "hw/core/tcg-cpu-ops.h" | ||
2181 | #endif /* CONFIG_TCG */ | ||
2182 | #include "internals.h" | ||
2183 | +#include "cpu-features.h" | ||
2184 | #include "exec/exec-all.h" | ||
2185 | #include "hw/qdev-properties.h" | ||
2186 | #if !defined(CONFIG_USER_ONLY) | ||
2187 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
2188 | index XXXXXXX..XXXXXXX 100644 | ||
2189 | --- a/target/arm/cpu64.c | ||
2190 | +++ b/target/arm/cpu64.c | ||
2191 | @@ -XXX,XX +XXX,XX @@ | ||
2192 | #include "qapi/visitor.h" | ||
2193 | #include "hw/qdev-properties.h" | ||
2194 | #include "internals.h" | ||
2195 | +#include "cpu-features.h" | ||
2196 | #include "cpregs.h" | ||
2197 | |||
2198 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
2199 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
2200 | index XXXXXXX..XXXXXXX 100644 | ||
2201 | --- a/target/arm/debug_helper.c | ||
2202 | +++ b/target/arm/debug_helper.c | ||
2203 | @@ -XXX,XX +XXX,XX @@ | ||
2204 | #include "qemu/log.h" | ||
2205 | #include "cpu.h" | ||
2206 | #include "internals.h" | ||
2207 | +#include "cpu-features.h" | ||
2208 | #include "cpregs.h" | ||
2209 | #include "exec/exec-all.h" | ||
2210 | #include "exec/helper-proto.h" | ||
2211 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
2212 | index XXXXXXX..XXXXXXX 100644 | ||
2213 | --- a/target/arm/gdbstub.c | ||
2214 | +++ b/target/arm/gdbstub.c | ||
2215 | @@ -XXX,XX +XXX,XX @@ | ||
2216 | #include "gdbstub/helpers.h" | ||
2217 | #include "sysemu/tcg.h" | ||
2218 | #include "internals.h" | ||
2219 | +#include "cpu-features.h" | ||
2220 | #include "cpregs.h" | ||
2221 | |||
2222 | typedef struct RegisterSysregXmlParam { | ||
2223 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
2224 | index XXXXXXX..XXXXXXX 100644 | ||
2225 | --- a/target/arm/helper.c | ||
2226 | +++ b/target/arm/helper.c | ||
2227 | @@ -XXX,XX +XXX,XX @@ | ||
2228 | #include "trace.h" | ||
2229 | #include "cpu.h" | ||
2230 | #include "internals.h" | ||
2231 | +#include "cpu-features.h" | ||
2232 | #include "exec/helper-proto.h" | ||
2233 | #include "qemu/main-loop.h" | ||
2234 | #include "qemu/timer.h" | ||
2235 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
2236 | index XXXXXXX..XXXXXXX 100644 | ||
2237 | --- a/target/arm/kvm64.c | ||
2238 | +++ b/target/arm/kvm64.c | ||
2239 | @@ -XXX,XX +XXX,XX @@ | ||
2240 | #include "sysemu/kvm_int.h" | ||
2241 | #include "kvm_arm.h" | ||
2242 | #include "internals.h" | ||
2243 | +#include "cpu-features.h" | ||
2244 | #include "hw/acpi/acpi.h" | ||
2245 | #include "hw/acpi/ghes.h" | ||
2246 | |||
2247 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
2248 | index XXXXXXX..XXXXXXX 100644 | ||
2249 | --- a/target/arm/machine.c | ||
2250 | +++ b/target/arm/machine.c | ||
2251 | @@ -XXX,XX +XXX,XX @@ | ||
2252 | #include "sysemu/tcg.h" | ||
2253 | #include "kvm_arm.h" | ||
2254 | #include "internals.h" | ||
2255 | +#include "cpu-features.h" | ||
2256 | #include "migration/cpu.h" | ||
2257 | |||
2258 | static bool vfp_needed(void *opaque) | ||
2259 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
2260 | index XXXXXXX..XXXXXXX 100644 | ||
2261 | --- a/target/arm/ptw.c | ||
2262 | +++ b/target/arm/ptw.c | ||
2263 | @@ -XXX,XX +XXX,XX @@ | ||
2264 | #include "exec/exec-all.h" | ||
2265 | #include "cpu.h" | ||
2266 | #include "internals.h" | ||
2267 | +#include "cpu-features.h" | ||
2268 | #include "idau.h" | ||
2269 | #ifdef CONFIG_TCG | ||
2270 | # include "tcg/oversized-guest.h" | ||
2271 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
2272 | index XXXXXXX..XXXXXXX 100644 | ||
2273 | --- a/target/arm/tcg/cpu64.c | ||
2274 | +++ b/target/arm/tcg/cpu64.c | ||
2275 | @@ -XXX,XX +XXX,XX @@ | ||
2276 | #include "hw/qdev-properties.h" | ||
2277 | #include "qemu/units.h" | ||
2278 | #include "internals.h" | ||
2279 | +#include "cpu-features.h" | ||
2280 | #include "cpregs.h" | ||
2281 | |||
2282 | static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize, | ||
2283 | diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c | ||
2284 | index XXXXXXX..XXXXXXX 100644 | ||
2285 | --- a/target/arm/tcg/hflags.c | ||
2286 | +++ b/target/arm/tcg/hflags.c | ||
2287 | @@ -XXX,XX +XXX,XX @@ | ||
2288 | #include "qemu/osdep.h" | ||
2289 | #include "cpu.h" | ||
2290 | #include "internals.h" | ||
2291 | +#include "cpu-features.h" | ||
2292 | #include "exec/helper-proto.h" | ||
2293 | #include "cpregs.h" | ||
2294 | |||
2295 | diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c | ||
2296 | index XXXXXXX..XXXXXXX 100644 | ||
2297 | --- a/target/arm/tcg/m_helper.c | ||
2298 | +++ b/target/arm/tcg/m_helper.c | ||
2299 | @@ -XXX,XX +XXX,XX @@ | ||
2300 | #include "qemu/osdep.h" | ||
2301 | #include "cpu.h" | ||
2302 | #include "internals.h" | ||
2303 | +#include "cpu-features.h" | ||
2304 | #include "gdbstub/helpers.h" | ||
2305 | #include "exec/helper-proto.h" | ||
2306 | #include "qemu/main-loop.h" | ||
2307 | diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c | ||
2308 | index XXXXXXX..XXXXXXX 100644 | ||
2309 | --- a/target/arm/tcg/op_helper.c | ||
2310 | +++ b/target/arm/tcg/op_helper.c | ||
2311 | @@ -XXX,XX +XXX,XX @@ | ||
2312 | #include "cpu.h" | ||
2313 | #include "exec/helper-proto.h" | ||
2314 | #include "internals.h" | ||
2315 | +#include "cpu-features.h" | ||
2316 | #include "exec/exec-all.h" | ||
2317 | #include "exec/cpu_ldst.h" | ||
2318 | #include "cpregs.h" | ||
2319 | diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c | ||
2320 | index XXXXXXX..XXXXXXX 100644 | ||
2321 | --- a/target/arm/tcg/pauth_helper.c | ||
2322 | +++ b/target/arm/tcg/pauth_helper.c | ||
2323 | @@ -XXX,XX +XXX,XX @@ | ||
2324 | #include "qemu/osdep.h" | ||
2325 | #include "cpu.h" | ||
2326 | #include "internals.h" | ||
2327 | +#include "cpu-features.h" | ||
2328 | #include "exec/exec-all.h" | ||
2329 | #include "exec/cpu_ldst.h" | ||
2330 | #include "exec/helper-proto.h" | ||
2331 | diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c | ||
2332 | index XXXXXXX..XXXXXXX 100644 | ||
2333 | --- a/target/arm/tcg/tlb_helper.c | ||
2334 | +++ b/target/arm/tcg/tlb_helper.c | ||
2335 | @@ -XXX,XX +XXX,XX @@ | ||
2336 | #include "qemu/osdep.h" | ||
2337 | #include "cpu.h" | ||
2338 | #include "internals.h" | ||
2339 | +#include "cpu-features.h" | ||
2340 | #include "exec/exec-all.h" | ||
2341 | #include "exec/helper-proto.h" | ||
2342 | |||
2343 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
2344 | index XXXXXXX..XXXXXXX 100644 | ||
2345 | --- a/target/arm/vfp_helper.c | ||
2346 | +++ b/target/arm/vfp_helper.c | ||
2347 | @@ -XXX,XX +XXX,XX @@ | ||
2348 | #include "cpu.h" | ||
2349 | #include "exec/helper-proto.h" | ||
2350 | #include "internals.h" | ||
2351 | +#include "cpu-features.h" | ||
2352 | #ifdef CONFIG_TCG | ||
2353 | #include "qemu/log.h" | ||
2354 | #include "fpu/softfloat.h" | ||
312 | -- | 2355 | -- |
313 | 2.20.1 | 2356 | 2.34.1 |
314 | 2357 | ||
315 | 2358 | diff view generated by jsdifflib |
1 | Move the specification of the IRQ information for the uart, ethernet, | 1 | Our list of isar_feature functions is not in any particular order, |
---|---|---|---|
2 | dma and spi devices to the data structures. (The other devices | 2 | but tests on fields of the same ID register tend to be grouped |
3 | handled by the PPCPortInfo structures don't have any interrupt lines | 3 | together. A few functions that are tests of fields in ID_AA64MMFR1 |
4 | we need to wire up.) | 4 | and ID_AA64MMFR2 are not in the same place as the rest; move them |
5 | into their groups. | ||
5 | 6 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210215115138.20465-14-peter.maydell@linaro.org | 10 | Message-id: 20231024163510.2972081-3-peter.maydell@linaro.org |
9 | --- | 11 | --- |
10 | hw/arm/mps2-tz.c | 52 +++++++++++++++++++++++------------------------- | 12 | target/arm/cpu-features.h | 60 +++++++++++++++++++-------------------- |
11 | 1 file changed, 25 insertions(+), 27 deletions(-) | 13 | 1 file changed, 30 insertions(+), 30 deletions(-) |
12 | 14 | ||
13 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/mps2-tz.c | 17 | --- a/target/arm/cpu-features.h |
16 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/target/arm/cpu-features.h |
17 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | 19 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_tidcp1(const ARMISARegisters *id) |
18 | const char *name, hwaddr size, | 20 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR1, TIDCP1) != 0; |
19 | const int *irqs) | 21 | } |
22 | |||
23 | +static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) | ||
24 | +{ | ||
25 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) != 0; | ||
26 | +} | ||
27 | + | ||
28 | +static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) | ||
29 | +{ | ||
30 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >= 2; | ||
31 | +} | ||
32 | + | ||
33 | +static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) | ||
34 | +{ | ||
35 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0; | ||
36 | +} | ||
37 | + | ||
38 | static inline bool isar_feature_aa64_uao(const ARMISARegisters *id) | ||
20 | { | 39 | { |
21 | + /* The irq[] array is tx, rx, combined, in that order */ | 40 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0; |
22 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 41 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_evt(const ARMISARegisters *id) |
23 | CMSDKAPBUART *uart = opaque; | 42 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 2; |
24 | int i = uart - &mms->uart[0]; | ||
25 | - int rxirqno = i * 2 + 32; | ||
26 | - int txirqno = i * 2 + 33; | ||
27 | - int combirqno = i + 42; | ||
28 | SysBusDevice *s; | ||
29 | DeviceState *orgate_dev = DEVICE(&mms->uart_irq_orgate); | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
32 | qdev_prop_set_uint32(DEVICE(uart), "pclk-frq", mmc->sysclk_frq); | ||
33 | sysbus_realize(SYS_BUS_DEVICE(uart), &error_fatal); | ||
34 | s = SYS_BUS_DEVICE(uart); | ||
35 | - sysbus_connect_irq(s, 0, get_sse_irq_in(mms, txirqno)); | ||
36 | - sysbus_connect_irq(s, 1, get_sse_irq_in(mms, rxirqno)); | ||
37 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqs[0])); | ||
38 | + sysbus_connect_irq(s, 1, get_sse_irq_in(mms, irqs[1])); | ||
39 | sysbus_connect_irq(s, 2, qdev_get_gpio_in(orgate_dev, i * 2)); | ||
40 | sysbus_connect_irq(s, 3, qdev_get_gpio_in(orgate_dev, i * 2 + 1)); | ||
41 | - sysbus_connect_irq(s, 4, get_sse_irq_in(mms, combirqno)); | ||
42 | + sysbus_connect_irq(s, 4, get_sse_irq_in(mms, irqs[2])); | ||
43 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(uart), 0); | ||
44 | } | 43 | } |
45 | 44 | ||
46 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | 45 | +static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) |
47 | 46 | +{ | |
48 | s = SYS_BUS_DEVICE(mms->lan9118); | 47 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0; |
49 | sysbus_realize_and_unref(s, &error_fatal); | 48 | +} |
50 | - sysbus_connect_irq(s, 0, get_sse_irq_in(mms, 48)); | 49 | + |
51 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqs[0])); | 50 | +static inline bool isar_feature_aa64_lva(const ARMISARegisters *id) |
52 | return sysbus_mmio_get_region(s, 0); | 51 | +{ |
52 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) != 0; | ||
53 | +} | ||
54 | + | ||
55 | +static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id) | ||
56 | +{ | ||
57 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0; | ||
58 | +} | ||
59 | + | ||
60 | static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
61 | { | ||
62 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
63 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) | ||
64 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; | ||
53 | } | 65 | } |
54 | 66 | ||
55 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | 67 | -static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) |
56 | const char *name, hwaddr size, | 68 | -{ |
57 | const int *irqs) | 69 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0; |
70 | -} | ||
71 | - | ||
72 | -static inline bool isar_feature_aa64_lva(const ARMISARegisters *id) | ||
73 | -{ | ||
74 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) != 0; | ||
75 | -} | ||
76 | - | ||
77 | -static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id) | ||
78 | -{ | ||
79 | - return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0; | ||
80 | -} | ||
81 | - | ||
82 | -static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) | ||
83 | -{ | ||
84 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) != 0; | ||
85 | -} | ||
86 | - | ||
87 | -static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) | ||
88 | -{ | ||
89 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >= 2; | ||
90 | -} | ||
91 | - | ||
92 | -static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) | ||
93 | -{ | ||
94 | - return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0; | ||
95 | -} | ||
96 | - | ||
97 | static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | ||
58 | { | 98 | { |
59 | + /* The irq[] array is DMACINTR, DMACINTERR, DMACINTTC, in that order */ | 99 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; |
60 | PL080State *dma = opaque; | ||
61 | int i = dma - &mms->dma[0]; | ||
62 | SysBusDevice *s; | ||
63 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | ||
64 | |||
65 | s = SYS_BUS_DEVICE(dma); | ||
66 | /* Wire up DMACINTR, DMACINTERR, DMACINTTC */ | ||
67 | - sysbus_connect_irq(s, 0, get_sse_irq_in(mms, 58 + i * 3)); | ||
68 | - sysbus_connect_irq(s, 1, get_sse_irq_in(mms, 56 + i * 3)); | ||
69 | - sysbus_connect_irq(s, 2, get_sse_irq_in(mms, 57 + i * 3)); | ||
70 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqs[0])); | ||
71 | + sysbus_connect_irq(s, 1, get_sse_irq_in(mms, irqs[1])); | ||
72 | + sysbus_connect_irq(s, 2, get_sse_irq_in(mms, irqs[2])); | ||
73 | |||
74 | g_free(mscname); | ||
75 | return sysbus_mmio_get_region(s, 0); | ||
76 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque, | ||
77 | * lines are set via the "MISC" register in the MPS2 FPGAIO device. | ||
78 | */ | ||
79 | PL022State *spi = opaque; | ||
80 | - int i = spi - &mms->spi[0]; | ||
81 | SysBusDevice *s; | ||
82 | |||
83 | object_initialize_child(OBJECT(mms), name, spi, TYPE_PL022); | ||
84 | sysbus_realize(SYS_BUS_DEVICE(spi), &error_fatal); | ||
85 | s = SYS_BUS_DEVICE(spi); | ||
86 | - sysbus_connect_irq(s, 0, get_sse_irq_in(mms, 51 + i)); | ||
87 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqs[0])); | ||
88 | return sysbus_mmio_get_region(s, 0); | ||
89 | } | ||
90 | |||
91 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
92 | }, { | ||
93 | .name = "apb_ppcexp1", | ||
94 | .ports = { | ||
95 | - { "spi0", make_spi, &mms->spi[0], 0x40205000, 0x1000 }, | ||
96 | - { "spi1", make_spi, &mms->spi[1], 0x40206000, 0x1000 }, | ||
97 | - { "spi2", make_spi, &mms->spi[2], 0x40209000, 0x1000 }, | ||
98 | - { "spi3", make_spi, &mms->spi[3], 0x4020a000, 0x1000 }, | ||
99 | - { "spi4", make_spi, &mms->spi[4], 0x4020b000, 0x1000 }, | ||
100 | - { "uart0", make_uart, &mms->uart[0], 0x40200000, 0x1000 }, | ||
101 | - { "uart1", make_uart, &mms->uart[1], 0x40201000, 0x1000 }, | ||
102 | - { "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 }, | ||
103 | - { "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000 }, | ||
104 | - { "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000 }, | ||
105 | + { "spi0", make_spi, &mms->spi[0], 0x40205000, 0x1000, { 51 } }, | ||
106 | + { "spi1", make_spi, &mms->spi[1], 0x40206000, 0x1000, { 52 } }, | ||
107 | + { "spi2", make_spi, &mms->spi[2], 0x40209000, 0x1000, { 53 } }, | ||
108 | + { "spi3", make_spi, &mms->spi[3], 0x4020a000, 0x1000, { 54 } }, | ||
109 | + { "spi4", make_spi, &mms->spi[4], 0x4020b000, 0x1000, { 55 } }, | ||
110 | + { "uart0", make_uart, &mms->uart[0], 0x40200000, 0x1000, { 32, 33, 42 } }, | ||
111 | + { "uart1", make_uart, &mms->uart[1], 0x40201000, 0x1000, { 34, 35, 43 } }, | ||
112 | + { "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000, { 36, 37, 44 } }, | ||
113 | + { "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000, { 38, 39, 45 } }, | ||
114 | + { "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000, { 40, 41, 46 } }, | ||
115 | { "i2c0", make_i2c, &mms->i2c[0], 0x40207000, 0x1000 }, | ||
116 | { "i2c1", make_i2c, &mms->i2c[1], 0x40208000, 0x1000 }, | ||
117 | { "i2c2", make_i2c, &mms->i2c[2], 0x4020c000, 0x1000 }, | ||
118 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
119 | { "gpio1", make_unimp_dev, &mms->gpio[1], 0x40101000, 0x1000 }, | ||
120 | { "gpio2", make_unimp_dev, &mms->gpio[2], 0x40102000, 0x1000 }, | ||
121 | { "gpio3", make_unimp_dev, &mms->gpio[3], 0x40103000, 0x1000 }, | ||
122 | - { "eth", make_eth_dev, NULL, 0x42000000, 0x100000 }, | ||
123 | + { "eth", make_eth_dev, NULL, 0x42000000, 0x100000, { 48 } }, | ||
124 | }, | ||
125 | }, { | ||
126 | .name = "ahb_ppcexp1", | ||
127 | .ports = { | ||
128 | - { "dma0", make_dma, &mms->dma[0], 0x40110000, 0x1000 }, | ||
129 | - { "dma1", make_dma, &mms->dma[1], 0x40111000, 0x1000 }, | ||
130 | - { "dma2", make_dma, &mms->dma[2], 0x40112000, 0x1000 }, | ||
131 | - { "dma3", make_dma, &mms->dma[3], 0x40113000, 0x1000 }, | ||
132 | + { "dma0", make_dma, &mms->dma[0], 0x40110000, 0x1000, { 58, 56, 57 } }, | ||
133 | + { "dma1", make_dma, &mms->dma[1], 0x40111000, 0x1000, { 61, 59, 60 } }, | ||
134 | + { "dma2", make_dma, &mms->dma[2], 0x40112000, 0x1000, { 64, 62, 63 } }, | ||
135 | + { "dma3", make_dma, &mms->dma[3], 0x40113000, 0x1000, { 67, 65, 66 } }, | ||
136 | }, | ||
137 | }, | ||
138 | }; | ||
139 | -- | 100 | -- |
140 | 2.20.1 | 101 | 2.34.1 |
141 | 102 | ||
142 | 103 | diff view generated by jsdifflib |
1 | From: Doug Evans <dje@google.com> | 1 | Move the ID_AA64MMFR0 feature test functions up so they are |
---|---|---|---|
2 | before the ones for ID_AA64MMFR1 and ID_AA64MMFR2. | ||
2 | 3 | ||
3 | Reviewed-by: Hao Wu <wuhaotsh@google.com> | ||
4 | Reviewed-by: Avi Fishman <avi.fishman@nuvoton.com> | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Doug Evans <dje@google.com> | ||
7 | Message-id: 20210218212453.831406-4-dje@google.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20231024163510.2972081-4-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | tests/qtest/npcm7xx_emc-test.c | 862 +++++++++++++++++++++++++++++++++ | 9 | target/arm/cpu-features.h | 120 +++++++++++++++++++------------------- |
11 | tests/qtest/meson.build | 3 +- | 10 | 1 file changed, 60 insertions(+), 60 deletions(-) |
12 | 2 files changed, 864 insertions(+), 1 deletion(-) | ||
13 | create mode 100644 tests/qtest/npcm7xx_emc-test.c | ||
14 | 11 | ||
15 | diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c | 12 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
16 | new file mode 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 14 | --- a/target/arm/cpu-features.h |
18 | --- /dev/null | 15 | +++ b/target/arm/cpu-features.h |
19 | +++ b/tests/qtest/npcm7xx_emc-test.c | 16 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_rme(const ARMISARegisters *id) |
20 | @@ -XXX,XX +XXX,XX @@ | 17 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RME) != 0; |
21 | +/* | 18 | } |
22 | + * QTests for Nuvoton NPCM7xx EMC Modules. | 19 | |
23 | + * | 20 | +static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) |
24 | + * Copyright 2020 Google LLC | ||
25 | + * | ||
26 | + * This program is free software; you can redistribute it and/or modify it | ||
27 | + * under the terms of the GNU General Public License as published by the | ||
28 | + * Free Software Foundation; either version 2 of the License, or | ||
29 | + * (at your option) any later version. | ||
30 | + * | ||
31 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
32 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
33 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
34 | + * for more details. | ||
35 | + */ | ||
36 | + | ||
37 | +#include "qemu/osdep.h" | ||
38 | +#include "qemu-common.h" | ||
39 | +#include "libqos/libqos.h" | ||
40 | +#include "qapi/qmp/qdict.h" | ||
41 | +#include "qapi/qmp/qnum.h" | ||
42 | +#include "qemu/bitops.h" | ||
43 | +#include "qemu/iov.h" | ||
44 | + | ||
45 | +/* Name of the emc device. */ | ||
46 | +#define TYPE_NPCM7XX_EMC "npcm7xx-emc" | ||
47 | + | ||
48 | +/* Timeout for various operations, in seconds. */ | ||
49 | +#define TIMEOUT_SECONDS 10 | ||
50 | + | ||
51 | +/* Address in memory of the descriptor. */ | ||
52 | +#define DESC_ADDR (1 << 20) /* 1 MiB */ | ||
53 | + | ||
54 | +/* Address in memory of the data packet. */ | ||
55 | +#define DATA_ADDR (DESC_ADDR + 4096) | ||
56 | + | ||
57 | +#define CRC_LENGTH 4 | ||
58 | + | ||
59 | +#define NUM_TX_DESCRIPTORS 3 | ||
60 | +#define NUM_RX_DESCRIPTORS 2 | ||
61 | + | ||
62 | +/* Size of tx,rx test buffers. */ | ||
63 | +#define TX_DATA_LEN 64 | ||
64 | +#define RX_DATA_LEN 64 | ||
65 | + | ||
66 | +#define TX_STEP_COUNT 10000 | ||
67 | +#define RX_STEP_COUNT 10000 | ||
68 | + | ||
69 | +/* 32-bit register indices. */ | ||
70 | +typedef enum NPCM7xxPWMRegister { | ||
71 | + /* Control registers. */ | ||
72 | + REG_CAMCMR, | ||
73 | + REG_CAMEN, | ||
74 | + | ||
75 | + /* There are 16 CAMn[ML] registers. */ | ||
76 | + REG_CAMM_BASE, | ||
77 | + REG_CAML_BASE, | ||
78 | + | ||
79 | + REG_TXDLSA = 0x22, | ||
80 | + REG_RXDLSA, | ||
81 | + REG_MCMDR, | ||
82 | + REG_MIID, | ||
83 | + REG_MIIDA, | ||
84 | + REG_FFTCR, | ||
85 | + REG_TSDR, | ||
86 | + REG_RSDR, | ||
87 | + REG_DMARFC, | ||
88 | + REG_MIEN, | ||
89 | + | ||
90 | + /* Status registers. */ | ||
91 | + REG_MISTA, | ||
92 | + REG_MGSTA, | ||
93 | + REG_MPCNT, | ||
94 | + REG_MRPC, | ||
95 | + REG_MRPCC, | ||
96 | + REG_MREPC, | ||
97 | + REG_DMARFS, | ||
98 | + REG_CTXDSA, | ||
99 | + REG_CTXBSA, | ||
100 | + REG_CRXDSA, | ||
101 | + REG_CRXBSA, | ||
102 | + | ||
103 | + NPCM7XX_NUM_EMC_REGS, | ||
104 | +} NPCM7xxPWMRegister; | ||
105 | + | ||
106 | +enum { NUM_CAMML_REGS = 16 }; | ||
107 | + | ||
108 | +/* REG_CAMCMR fields */ | ||
109 | +/* Enable CAM Compare */ | ||
110 | +#define REG_CAMCMR_ECMP (1 << 4) | ||
111 | +/* Accept Unicast Packet */ | ||
112 | +#define REG_CAMCMR_AUP (1 << 0) | ||
113 | + | ||
114 | +/* REG_MCMDR fields */ | ||
115 | +/* Software Reset */ | ||
116 | +#define REG_MCMDR_SWR (1 << 24) | ||
117 | +/* Frame Transmission On */ | ||
118 | +#define REG_MCMDR_TXON (1 << 8) | ||
119 | +/* Accept Long Packet */ | ||
120 | +#define REG_MCMDR_ALP (1 << 1) | ||
121 | +/* Frame Reception On */ | ||
122 | +#define REG_MCMDR_RXON (1 << 0) | ||
123 | + | ||
124 | +/* REG_MIEN fields */ | ||
125 | +/* Enable Transmit Completion Interrupt */ | ||
126 | +#define REG_MIEN_ENTXCP (1 << 18) | ||
127 | +/* Enable Transmit Interrupt */ | ||
128 | +#define REG_MIEN_ENTXINTR (1 << 16) | ||
129 | +/* Enable Receive Good Interrupt */ | ||
130 | +#define REG_MIEN_ENRXGD (1 << 4) | ||
131 | +/* ENable Receive Interrupt */ | ||
132 | +#define REG_MIEN_ENRXINTR (1 << 0) | ||
133 | + | ||
134 | +/* REG_MISTA fields */ | ||
135 | +/* Transmit Bus Error Interrupt */ | ||
136 | +#define REG_MISTA_TXBERR (1 << 24) | ||
137 | +/* Transmit Descriptor Unavailable Interrupt */ | ||
138 | +#define REG_MISTA_TDU (1 << 23) | ||
139 | +/* Transmit Completion Interrupt */ | ||
140 | +#define REG_MISTA_TXCP (1 << 18) | ||
141 | +/* Transmit Interrupt */ | ||
142 | +#define REG_MISTA_TXINTR (1 << 16) | ||
143 | +/* Receive Bus Error Interrupt */ | ||
144 | +#define REG_MISTA_RXBERR (1 << 11) | ||
145 | +/* Receive Descriptor Unavailable Interrupt */ | ||
146 | +#define REG_MISTA_RDU (1 << 10) | ||
147 | +/* DMA Early Notification Interrupt */ | ||
148 | +#define REG_MISTA_DENI (1 << 9) | ||
149 | +/* Maximum Frame Length Interrupt */ | ||
150 | +#define REG_MISTA_DFOI (1 << 8) | ||
151 | +/* Receive Good Interrupt */ | ||
152 | +#define REG_MISTA_RXGD (1 << 4) | ||
153 | +/* Packet Too Long Interrupt */ | ||
154 | +#define REG_MISTA_PTLE (1 << 3) | ||
155 | +/* Receive Interrupt */ | ||
156 | +#define REG_MISTA_RXINTR (1 << 0) | ||
157 | + | ||
158 | +typedef struct NPCM7xxEMCTxDesc NPCM7xxEMCTxDesc; | ||
159 | +typedef struct NPCM7xxEMCRxDesc NPCM7xxEMCRxDesc; | ||
160 | + | ||
161 | +struct NPCM7xxEMCTxDesc { | ||
162 | + uint32_t flags; | ||
163 | + uint32_t txbsa; | ||
164 | + uint32_t status_and_length; | ||
165 | + uint32_t ntxdsa; | ||
166 | +}; | ||
167 | + | ||
168 | +struct NPCM7xxEMCRxDesc { | ||
169 | + uint32_t status_and_length; | ||
170 | + uint32_t rxbsa; | ||
171 | + uint32_t reserved; | ||
172 | + uint32_t nrxdsa; | ||
173 | +}; | ||
174 | + | ||
175 | +/* NPCM7xxEMCTxDesc.flags values */ | ||
176 | +/* Owner: 0 = cpu, 1 = emc */ | ||
177 | +#define TX_DESC_FLAG_OWNER_MASK (1 << 31) | ||
178 | +/* Transmit interrupt enable */ | ||
179 | +#define TX_DESC_FLAG_INTEN (1 << 2) | ||
180 | + | ||
181 | +/* NPCM7xxEMCTxDesc.status_and_length values */ | ||
182 | +/* Transmission complete */ | ||
183 | +#define TX_DESC_STATUS_TXCP (1 << 19) | ||
184 | +/* Transmit interrupt */ | ||
185 | +#define TX_DESC_STATUS_TXINTR (1 << 16) | ||
186 | + | ||
187 | +/* NPCM7xxEMCRxDesc.status_and_length values */ | ||
188 | +/* Owner: 0b00 = cpu, 0b10 = emc */ | ||
189 | +#define RX_DESC_STATUS_OWNER_SHIFT 30 | ||
190 | +#define RX_DESC_STATUS_OWNER_MASK 0xc0000000 | ||
191 | +/* Frame Reception Complete */ | ||
192 | +#define RX_DESC_STATUS_RXGD (1 << 20) | ||
193 | +/* Packet too long */ | ||
194 | +#define RX_DESC_STATUS_PTLE (1 << 19) | ||
195 | +/* Receive Interrupt */ | ||
196 | +#define RX_DESC_STATUS_RXINTR (1 << 16) | ||
197 | + | ||
198 | +#define RX_DESC_PKT_LEN(word) ((uint32_t) (word) & 0xffff) | ||
199 | + | ||
200 | +typedef struct EMCModule { | ||
201 | + int rx_irq; | ||
202 | + int tx_irq; | ||
203 | + uint64_t base_addr; | ||
204 | +} EMCModule; | ||
205 | + | ||
206 | +typedef struct TestData { | ||
207 | + const EMCModule *module; | ||
208 | +} TestData; | ||
209 | + | ||
210 | +static const EMCModule emc_module_list[] = { | ||
211 | + { | ||
212 | + .rx_irq = 15, | ||
213 | + .tx_irq = 16, | ||
214 | + .base_addr = 0xf0825000 | ||
215 | + }, | ||
216 | + { | ||
217 | + .rx_irq = 114, | ||
218 | + .tx_irq = 115, | ||
219 | + .base_addr = 0xf0826000 | ||
220 | + } | ||
221 | +}; | ||
222 | + | ||
223 | +/* Returns the index of the EMC module. */ | ||
224 | +static int emc_module_index(const EMCModule *mod) | ||
225 | +{ | 21 | +{ |
226 | + ptrdiff_t diff = mod - emc_module_list; | 22 | + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1; |
227 | + | ||
228 | + g_assert_true(diff >= 0 && diff < ARRAY_SIZE(emc_module_list)); | ||
229 | + | ||
230 | + return diff; | ||
231 | +} | 23 | +} |
232 | + | 24 | + |
233 | +static void packet_test_clear(void *sockets) | 25 | +static inline bool isar_feature_aa64_tgran4_2_lpa2(const ARMISARegisters *id) |
234 | +{ | 26 | +{ |
235 | + int *test_sockets = sockets; | 27 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); |
236 | + | 28 | + return t >= 3 || (t == 0 && isar_feature_aa64_tgran4_lpa2(id)); |
237 | + close(test_sockets[0]); | ||
238 | + g_free(test_sockets); | ||
239 | +} | 29 | +} |
240 | + | 30 | + |
241 | +static int *packet_test_init(int module_num, GString *cmd_line) | 31 | +static inline bool isar_feature_aa64_tgran16_lpa2(const ARMISARegisters *id) |
242 | +{ | 32 | +{ |
243 | + int *test_sockets = g_new(int, 2); | 33 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 2; |
244 | + int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, test_sockets); | ||
245 | + g_assert_cmpint(ret, != , -1); | ||
246 | + | ||
247 | + /* | ||
248 | + * KISS and use -nic. We specify two nics (both emc{0,1}) because there's | ||
249 | + * currently no way to specify only emc1: The driver implicitly relies on | ||
250 | + * emc[i] == nd_table[i]. | ||
251 | + */ | ||
252 | + if (module_num == 0) { | ||
253 | + g_string_append_printf(cmd_line, | ||
254 | + " -nic socket,fd=%d,model=" TYPE_NPCM7XX_EMC " " | ||
255 | + " -nic user,model=" TYPE_NPCM7XX_EMC " ", | ||
256 | + test_sockets[1]); | ||
257 | + } else { | ||
258 | + g_string_append_printf(cmd_line, | ||
259 | + " -nic user,model=" TYPE_NPCM7XX_EMC " " | ||
260 | + " -nic socket,fd=%d,model=" TYPE_NPCM7XX_EMC " ", | ||
261 | + test_sockets[1]); | ||
262 | + } | ||
263 | + | ||
264 | + g_test_queue_destroy(packet_test_clear, test_sockets); | ||
265 | + return test_sockets; | ||
266 | +} | 34 | +} |
267 | + | 35 | + |
268 | +static uint32_t emc_read(QTestState *qts, const EMCModule *mod, | 36 | +static inline bool isar_feature_aa64_tgran16_2_lpa2(const ARMISARegisters *id) |
269 | + NPCM7xxPWMRegister regno) | ||
270 | +{ | 37 | +{ |
271 | + return qtest_readl(qts, mod->base_addr + regno * sizeof(uint32_t)); | 38 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); |
39 | + return t >= 3 || (t == 0 && isar_feature_aa64_tgran16_lpa2(id)); | ||
272 | +} | 40 | +} |
273 | + | 41 | + |
274 | +static void emc_write(QTestState *qts, const EMCModule *mod, | 42 | +static inline bool isar_feature_aa64_tgran4(const ARMISARegisters *id) |
275 | + NPCM7xxPWMRegister regno, uint32_t value) | ||
276 | +{ | 43 | +{ |
277 | + qtest_writel(qts, mod->base_addr + regno * sizeof(uint32_t), value); | 44 | + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 0; |
278 | +} | 45 | +} |
279 | + | 46 | + |
280 | +static void emc_read_tx_desc(QTestState *qts, uint32_t addr, | 47 | +static inline bool isar_feature_aa64_tgran16(const ARMISARegisters *id) |
281 | + NPCM7xxEMCTxDesc *desc) | ||
282 | +{ | 48 | +{ |
283 | + qtest_memread(qts, addr, desc, sizeof(*desc)); | 49 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 1; |
284 | + desc->flags = le32_to_cpu(desc->flags); | ||
285 | + desc->txbsa = le32_to_cpu(desc->txbsa); | ||
286 | + desc->status_and_length = le32_to_cpu(desc->status_and_length); | ||
287 | + desc->ntxdsa = le32_to_cpu(desc->ntxdsa); | ||
288 | +} | 50 | +} |
289 | + | 51 | + |
290 | +static void emc_write_tx_desc(QTestState *qts, const NPCM7xxEMCTxDesc *desc, | 52 | +static inline bool isar_feature_aa64_tgran64(const ARMISARegisters *id) |
291 | + uint32_t addr) | ||
292 | +{ | 53 | +{ |
293 | + NPCM7xxEMCTxDesc le_desc; | 54 | + return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64) >= 0; |
294 | + | ||
295 | + le_desc.flags = cpu_to_le32(desc->flags); | ||
296 | + le_desc.txbsa = cpu_to_le32(desc->txbsa); | ||
297 | + le_desc.status_and_length = cpu_to_le32(desc->status_and_length); | ||
298 | + le_desc.ntxdsa = cpu_to_le32(desc->ntxdsa); | ||
299 | + qtest_memwrite(qts, addr, &le_desc, sizeof(le_desc)); | ||
300 | +} | 55 | +} |
301 | + | 56 | + |
302 | +static void emc_read_rx_desc(QTestState *qts, uint32_t addr, | 57 | +static inline bool isar_feature_aa64_tgran4_2(const ARMISARegisters *id) |
303 | + NPCM7xxEMCRxDesc *desc) | ||
304 | +{ | 58 | +{ |
305 | + qtest_memread(qts, addr, desc, sizeof(*desc)); | 59 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); |
306 | + desc->status_and_length = le32_to_cpu(desc->status_and_length); | 60 | + return t >= 2 || (t == 0 && isar_feature_aa64_tgran4(id)); |
307 | + desc->rxbsa = le32_to_cpu(desc->rxbsa); | ||
308 | + desc->reserved = le32_to_cpu(desc->reserved); | ||
309 | + desc->nrxdsa = le32_to_cpu(desc->nrxdsa); | ||
310 | +} | 61 | +} |
311 | + | 62 | + |
312 | +static void emc_write_rx_desc(QTestState *qts, const NPCM7xxEMCRxDesc *desc, | 63 | +static inline bool isar_feature_aa64_tgran16_2(const ARMISARegisters *id) |
313 | + uint32_t addr) | ||
314 | +{ | 64 | +{ |
315 | + NPCM7xxEMCRxDesc le_desc; | 65 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); |
316 | + | 66 | + return t >= 2 || (t == 0 && isar_feature_aa64_tgran16(id)); |
317 | + le_desc.status_and_length = cpu_to_le32(desc->status_and_length); | ||
318 | + le_desc.rxbsa = cpu_to_le32(desc->rxbsa); | ||
319 | + le_desc.reserved = cpu_to_le32(desc->reserved); | ||
320 | + le_desc.nrxdsa = cpu_to_le32(desc->nrxdsa); | ||
321 | + qtest_memwrite(qts, addr, &le_desc, sizeof(le_desc)); | ||
322 | +} | 67 | +} |
323 | + | 68 | + |
324 | +/* | 69 | +static inline bool isar_feature_aa64_tgran64_2(const ARMISARegisters *id) |
325 | + * Reset the EMC module. | ||
326 | + * The module must be reset before, e.g., TXDLSA,RXDLSA are changed. | ||
327 | + */ | ||
328 | +static bool emc_soft_reset(QTestState *qts, const EMCModule *mod) | ||
329 | +{ | 70 | +{ |
330 | + uint32_t val; | 71 | + unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64_2); |
331 | + uint64_t end_time; | 72 | + return t >= 2 || (t == 0 && isar_feature_aa64_tgran64(id)); |
332 | + | ||
333 | + emc_write(qts, mod, REG_MCMDR, REG_MCMDR_SWR); | ||
334 | + | ||
335 | + /* | ||
336 | + * Wait for device to reset as the linux driver does. | ||
337 | + * During reset the AHB reads 0 for all registers. So first wait for | ||
338 | + * something that resets to non-zero, and then wait for SWR becoming 0. | ||
339 | + */ | ||
340 | + end_time = g_get_monotonic_time() + TIMEOUT_SECONDS * G_TIME_SPAN_SECOND; | ||
341 | + | ||
342 | + do { | ||
343 | + qtest_clock_step(qts, 100); | ||
344 | + val = emc_read(qts, mod, REG_FFTCR); | ||
345 | + } while (val == 0 && g_get_monotonic_time() < end_time); | ||
346 | + if (val != 0) { | ||
347 | + do { | ||
348 | + qtest_clock_step(qts, 100); | ||
349 | + val = emc_read(qts, mod, REG_MCMDR); | ||
350 | + if ((val & REG_MCMDR_SWR) == 0) { | ||
351 | + /* | ||
352 | + * N.B. The CAMs have been reset here, so macaddr matching of | ||
353 | + * incoming packets will not work. | ||
354 | + */ | ||
355 | + return true; | ||
356 | + } | ||
357 | + } while (g_get_monotonic_time() < end_time); | ||
358 | + } | ||
359 | + | ||
360 | + g_message("%s: Timeout expired", __func__); | ||
361 | + return false; | ||
362 | +} | 73 | +} |
363 | + | 74 | + |
364 | +/* Check emc registers are reset to default value. */ | 75 | +static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
365 | +static void test_init(gconstpointer test_data) | ||
366 | +{ | 76 | +{ |
367 | + const TestData *td = test_data; | 77 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
368 | + const EMCModule *mod = td->module; | ||
369 | + QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
370 | + int i; | ||
371 | + | ||
372 | +#define CHECK_REG(regno, value) \ | ||
373 | + do { \ | ||
374 | + g_assert_cmphex(emc_read(qts, mod, (regno)), ==, (value)); \ | ||
375 | + } while (0) | ||
376 | + | ||
377 | + CHECK_REG(REG_CAMCMR, 0); | ||
378 | + CHECK_REG(REG_CAMEN, 0); | ||
379 | + CHECK_REG(REG_TXDLSA, 0xfffffffc); | ||
380 | + CHECK_REG(REG_RXDLSA, 0xfffffffc); | ||
381 | + CHECK_REG(REG_MCMDR, 0); | ||
382 | + CHECK_REG(REG_MIID, 0); | ||
383 | + CHECK_REG(REG_MIIDA, 0x00900000); | ||
384 | + CHECK_REG(REG_FFTCR, 0x0101); | ||
385 | + CHECK_REG(REG_DMARFC, 0x0800); | ||
386 | + CHECK_REG(REG_MIEN, 0); | ||
387 | + CHECK_REG(REG_MISTA, 0); | ||
388 | + CHECK_REG(REG_MGSTA, 0); | ||
389 | + CHECK_REG(REG_MPCNT, 0x7fff); | ||
390 | + CHECK_REG(REG_MRPC, 0); | ||
391 | + CHECK_REG(REG_MRPCC, 0); | ||
392 | + CHECK_REG(REG_MREPC, 0); | ||
393 | + CHECK_REG(REG_DMARFS, 0); | ||
394 | + CHECK_REG(REG_CTXDSA, 0); | ||
395 | + CHECK_REG(REG_CTXBSA, 0); | ||
396 | + CHECK_REG(REG_CRXDSA, 0); | ||
397 | + CHECK_REG(REG_CRXBSA, 0); | ||
398 | + | ||
399 | +#undef CHECK_REG | ||
400 | + | ||
401 | + for (i = 0; i < NUM_CAMML_REGS; ++i) { | ||
402 | + g_assert_cmpuint(emc_read(qts, mod, REG_CAMM_BASE + i * 2), ==, | ||
403 | + 0); | ||
404 | + g_assert_cmpuint(emc_read(qts, mod, REG_CAML_BASE + i * 2), ==, | ||
405 | + 0); | ||
406 | + } | ||
407 | + | ||
408 | + qtest_quit(qts); | ||
409 | +} | 78 | +} |
410 | + | 79 | + |
411 | +static bool emc_wait_irq(QTestState *qts, const EMCModule *mod, int step, | 80 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
412 | + bool is_tx) | 81 | { |
413 | +{ | 82 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; |
414 | + uint64_t end_time = | 83 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_hbc(const ARMISARegisters *id) |
415 | + g_get_monotonic_time() + TIMEOUT_SECONDS * G_TIME_SPAN_SECOND; | 84 | return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, BC) != 0; |
416 | + | 85 | } |
417 | + do { | 86 | |
418 | + if (qtest_get_irq(qts, is_tx ? mod->tx_irq : mod->rx_irq)) { | 87 | -static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) |
419 | + return true; | 88 | -{ |
420 | + } | 89 | - return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1; |
421 | + qtest_clock_step(qts, step); | 90 | -} |
422 | + } while (g_get_monotonic_time() < end_time); | 91 | - |
423 | + | 92 | -static inline bool isar_feature_aa64_tgran4_2_lpa2(const ARMISARegisters *id) |
424 | + g_message("%s: Timeout expired", __func__); | 93 | -{ |
425 | + return false; | 94 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); |
426 | +} | 95 | - return t >= 3 || (t == 0 && isar_feature_aa64_tgran4_lpa2(id)); |
427 | + | 96 | -} |
428 | +static bool emc_wait_mista(QTestState *qts, const EMCModule *mod, int step, | 97 | - |
429 | + uint32_t flag) | 98 | -static inline bool isar_feature_aa64_tgran16_lpa2(const ARMISARegisters *id) |
430 | +{ | 99 | -{ |
431 | + uint64_t end_time = | 100 | - return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 2; |
432 | + g_get_monotonic_time() + TIMEOUT_SECONDS * G_TIME_SPAN_SECOND; | 101 | -} |
433 | + | 102 | - |
434 | + do { | 103 | -static inline bool isar_feature_aa64_tgran16_2_lpa2(const ARMISARegisters *id) |
435 | + uint32_t mista = emc_read(qts, mod, REG_MISTA); | 104 | -{ |
436 | + if (mista & flag) { | 105 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); |
437 | + return true; | 106 | - return t >= 3 || (t == 0 && isar_feature_aa64_tgran16_lpa2(id)); |
438 | + } | 107 | -} |
439 | + qtest_clock_step(qts, step); | 108 | - |
440 | + } while (g_get_monotonic_time() < end_time); | 109 | -static inline bool isar_feature_aa64_tgran4(const ARMISARegisters *id) |
441 | + | 110 | -{ |
442 | + g_message("%s: Timeout expired", __func__); | 111 | - return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 0; |
443 | + return false; | 112 | -} |
444 | +} | 113 | - |
445 | + | 114 | -static inline bool isar_feature_aa64_tgran16(const ARMISARegisters *id) |
446 | +static bool wait_socket_readable(int fd) | 115 | -{ |
447 | +{ | 116 | - return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16) >= 1; |
448 | + fd_set read_fds; | 117 | -} |
449 | + struct timeval tv; | 118 | - |
450 | + int rv; | 119 | -static inline bool isar_feature_aa64_tgran64(const ARMISARegisters *id) |
451 | + | 120 | -{ |
452 | + FD_ZERO(&read_fds); | 121 | - return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64) >= 0; |
453 | + FD_SET(fd, &read_fds); | 122 | -} |
454 | + tv.tv_sec = TIMEOUT_SECONDS; | 123 | - |
455 | + tv.tv_usec = 0; | 124 | -static inline bool isar_feature_aa64_tgran4_2(const ARMISARegisters *id) |
456 | + rv = select(fd + 1, &read_fds, NULL, NULL, &tv); | 125 | -{ |
457 | + if (rv == -1) { | 126 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4_2); |
458 | + perror("select"); | 127 | - return t >= 2 || (t == 0 && isar_feature_aa64_tgran4(id)); |
459 | + } else if (rv == 0) { | 128 | -} |
460 | + g_message("%s: Timeout expired", __func__); | 129 | - |
461 | + } | 130 | -static inline bool isar_feature_aa64_tgran16_2(const ARMISARegisters *id) |
462 | + return rv == 1; | 131 | -{ |
463 | +} | 132 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN16_2); |
464 | + | 133 | - return t >= 2 || (t == 0 && isar_feature_aa64_tgran16(id)); |
465 | +/* Initialize *desc (in host endian format). */ | 134 | -} |
466 | +static void init_tx_desc(NPCM7xxEMCTxDesc *desc, size_t count, | 135 | - |
467 | + uint32_t desc_addr) | 136 | -static inline bool isar_feature_aa64_tgran64_2(const ARMISARegisters *id) |
468 | +{ | 137 | -{ |
469 | + g_assert(count >= 2); | 138 | - unsigned t = FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN64_2); |
470 | + memset(&desc[0], 0, sizeof(*desc) * count); | 139 | - return t >= 2 || (t == 0 && isar_feature_aa64_tgran64(id)); |
471 | + /* Leave the last one alone, owned by the cpu -> stops transmission. */ | 140 | -} |
472 | + for (size_t i = 0; i < count - 1; ++i) { | 141 | - |
473 | + desc[i].flags = | 142 | -static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
474 | + (TX_DESC_FLAG_OWNER_MASK | /* owner = 1: emc */ | 143 | -{ |
475 | + TX_DESC_FLAG_INTEN | | 144 | - return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
476 | + 0 | /* crc append = 0 */ | 145 | -} |
477 | + 0 /* padding enable = 0 */); | 146 | - |
478 | + desc[i].status_and_length = | 147 | static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) |
479 | + (0 | /* collision count = 0 */ | 148 | { |
480 | + 0 | /* SQE = 0 */ | 149 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; |
481 | + 0 | /* PAU = 0 */ | ||
482 | + 0 | /* TXHA = 0 */ | ||
483 | + 0 | /* LC = 0 */ | ||
484 | + 0 | /* TXABT = 0 */ | ||
485 | + 0 | /* NCS = 0 */ | ||
486 | + 0 | /* EXDEF = 0 */ | ||
487 | + 0 | /* TXCP = 0 */ | ||
488 | + 0 | /* DEF = 0 */ | ||
489 | + 0 | /* TXINTR = 0 */ | ||
490 | + 0 /* length filled in later */); | ||
491 | + desc[i].ntxdsa = desc_addr + (i + 1) * sizeof(*desc); | ||
492 | + } | ||
493 | +} | ||
494 | + | ||
495 | +static void enable_tx(QTestState *qts, const EMCModule *mod, | ||
496 | + const NPCM7xxEMCTxDesc *desc, size_t count, | ||
497 | + uint32_t desc_addr, uint32_t mien_flags) | ||
498 | +{ | ||
499 | + /* Write the descriptors to guest memory. */ | ||
500 | + for (size_t i = 0; i < count; ++i) { | ||
501 | + emc_write_tx_desc(qts, desc + i, desc_addr + i * sizeof(*desc)); | ||
502 | + } | ||
503 | + | ||
504 | + /* Trigger sending the packet. */ | ||
505 | + /* The module must be reset before changing TXDLSA. */ | ||
506 | + g_assert(emc_soft_reset(qts, mod)); | ||
507 | + emc_write(qts, mod, REG_TXDLSA, desc_addr); | ||
508 | + emc_write(qts, mod, REG_CTXDSA, ~0); | ||
509 | + emc_write(qts, mod, REG_MIEN, REG_MIEN_ENTXCP | mien_flags); | ||
510 | + { | ||
511 | + uint32_t mcmdr = emc_read(qts, mod, REG_MCMDR); | ||
512 | + mcmdr |= REG_MCMDR_TXON; | ||
513 | + emc_write(qts, mod, REG_MCMDR, mcmdr); | ||
514 | + } | ||
515 | + | ||
516 | + /* Prod the device to send the packet. */ | ||
517 | + emc_write(qts, mod, REG_TSDR, 1); | ||
518 | +} | ||
519 | + | ||
520 | +static void emc_send_verify1(QTestState *qts, const EMCModule *mod, int fd, | ||
521 | + bool with_irq, uint32_t desc_addr, | ||
522 | + uint32_t next_desc_addr, | ||
523 | + const char *test_data, int test_size) | ||
524 | +{ | ||
525 | + NPCM7xxEMCTxDesc result_desc; | ||
526 | + uint32_t expected_mask, expected_value, recv_len; | ||
527 | + int ret; | ||
528 | + char buffer[TX_DATA_LEN]; | ||
529 | + | ||
530 | + g_assert(wait_socket_readable(fd)); | ||
531 | + | ||
532 | + /* Read the descriptor back. */ | ||
533 | + emc_read_tx_desc(qts, desc_addr, &result_desc); | ||
534 | + /* Descriptor should be owned by cpu now. */ | ||
535 | + g_assert((result_desc.flags & TX_DESC_FLAG_OWNER_MASK) == 0); | ||
536 | + /* Test the status bits, ignoring the length field. */ | ||
537 | + expected_mask = 0xffff << 16; | ||
538 | + expected_value = TX_DESC_STATUS_TXCP; | ||
539 | + if (with_irq) { | ||
540 | + expected_value |= TX_DESC_STATUS_TXINTR; | ||
541 | + } | ||
542 | + g_assert_cmphex((result_desc.status_and_length & expected_mask), ==, | ||
543 | + expected_value); | ||
544 | + | ||
545 | + /* Check data sent to the backend. */ | ||
546 | + recv_len = ~0; | ||
547 | + ret = qemu_recv(fd, &recv_len, sizeof(recv_len), MSG_DONTWAIT); | ||
548 | + g_assert_cmpint(ret, == , sizeof(recv_len)); | ||
549 | + | ||
550 | + g_assert(wait_socket_readable(fd)); | ||
551 | + memset(buffer, 0xff, sizeof(buffer)); | ||
552 | + ret = qemu_recv(fd, buffer, test_size, MSG_DONTWAIT); | ||
553 | + g_assert_cmpmem(buffer, ret, test_data, test_size); | ||
554 | +} | ||
555 | + | ||
556 | +static void emc_send_verify(QTestState *qts, const EMCModule *mod, int fd, | ||
557 | + bool with_irq) | ||
558 | +{ | ||
559 | + NPCM7xxEMCTxDesc desc[NUM_TX_DESCRIPTORS]; | ||
560 | + uint32_t desc_addr = DESC_ADDR; | ||
561 | + static const char test1_data[] = "TEST1"; | ||
562 | + static const char test2_data[] = "Testing 1 2 3 ..."; | ||
563 | + uint32_t data1_addr = DATA_ADDR; | ||
564 | + uint32_t data2_addr = data1_addr + sizeof(test1_data); | ||
565 | + bool got_tdu; | ||
566 | + uint32_t end_desc_addr; | ||
567 | + | ||
568 | + /* Prepare test data buffer. */ | ||
569 | + qtest_memwrite(qts, data1_addr, test1_data, sizeof(test1_data)); | ||
570 | + qtest_memwrite(qts, data2_addr, test2_data, sizeof(test2_data)); | ||
571 | + | ||
572 | + init_tx_desc(&desc[0], NUM_TX_DESCRIPTORS, desc_addr); | ||
573 | + desc[0].txbsa = data1_addr; | ||
574 | + desc[0].status_and_length |= sizeof(test1_data); | ||
575 | + desc[1].txbsa = data2_addr; | ||
576 | + desc[1].status_and_length |= sizeof(test2_data); | ||
577 | + | ||
578 | + enable_tx(qts, mod, &desc[0], NUM_TX_DESCRIPTORS, desc_addr, | ||
579 | + with_irq ? REG_MIEN_ENTXINTR : 0); | ||
580 | + | ||
581 | + /* | ||
582 | + * It's problematic to observe the interrupt for each packet. | ||
583 | + * Instead just wait until all the packets go out. | ||
584 | + */ | ||
585 | + got_tdu = false; | ||
586 | + while (!got_tdu) { | ||
587 | + if (with_irq) { | ||
588 | + g_assert_true(emc_wait_irq(qts, mod, TX_STEP_COUNT, | ||
589 | + /*is_tx=*/true)); | ||
590 | + } else { | ||
591 | + g_assert_true(emc_wait_mista(qts, mod, TX_STEP_COUNT, | ||
592 | + REG_MISTA_TXINTR)); | ||
593 | + } | ||
594 | + got_tdu = !!(emc_read(qts, mod, REG_MISTA) & REG_MISTA_TDU); | ||
595 | + /* If we don't have TDU yet, reset the interrupt. */ | ||
596 | + if (!got_tdu) { | ||
597 | + emc_write(qts, mod, REG_MISTA, | ||
598 | + emc_read(qts, mod, REG_MISTA) & 0xffff0000); | ||
599 | + } | ||
600 | + } | ||
601 | + | ||
602 | + end_desc_addr = desc_addr + 2 * sizeof(desc[0]); | ||
603 | + g_assert_cmphex(emc_read(qts, mod, REG_CTXDSA), ==, end_desc_addr); | ||
604 | + g_assert_cmphex(emc_read(qts, mod, REG_MISTA), ==, | ||
605 | + REG_MISTA_TXCP | REG_MISTA_TXINTR | REG_MISTA_TDU); | ||
606 | + | ||
607 | + emc_send_verify1(qts, mod, fd, with_irq, | ||
608 | + desc_addr, end_desc_addr, | ||
609 | + test1_data, sizeof(test1_data)); | ||
610 | + emc_send_verify1(qts, mod, fd, with_irq, | ||
611 | + desc_addr + sizeof(desc[0]), end_desc_addr, | ||
612 | + test2_data, sizeof(test2_data)); | ||
613 | +} | ||
614 | + | ||
615 | +/* Initialize *desc (in host endian format). */ | ||
616 | +static void init_rx_desc(NPCM7xxEMCRxDesc *desc, size_t count, | ||
617 | + uint32_t desc_addr, uint32_t data_addr) | ||
618 | +{ | ||
619 | + g_assert_true(count >= 2); | ||
620 | + memset(desc, 0, sizeof(*desc) * count); | ||
621 | + desc[0].rxbsa = data_addr; | ||
622 | + desc[0].status_and_length = | ||
623 | + (0b10 << RX_DESC_STATUS_OWNER_SHIFT | /* owner = 10: emc */ | ||
624 | + 0 | /* RP = 0 */ | ||
625 | + 0 | /* ALIE = 0 */ | ||
626 | + 0 | /* RXGD = 0 */ | ||
627 | + 0 | /* PTLE = 0 */ | ||
628 | + 0 | /* CRCE = 0 */ | ||
629 | + 0 | /* RXINTR = 0 */ | ||
630 | + 0 /* length (filled in later) */); | ||
631 | + /* Leave the last one alone, owned by the cpu -> stops transmission. */ | ||
632 | + desc[0].nrxdsa = desc_addr + sizeof(*desc); | ||
633 | +} | ||
634 | + | ||
635 | +static void enable_rx(QTestState *qts, const EMCModule *mod, | ||
636 | + const NPCM7xxEMCRxDesc *desc, size_t count, | ||
637 | + uint32_t desc_addr, uint32_t mien_flags, | ||
638 | + uint32_t mcmdr_flags) | ||
639 | +{ | ||
640 | + /* | ||
641 | + * Write the descriptor to guest memory. | ||
642 | + * FWIW, IWBN if the docs said the buffer needs to be at least DMARFC | ||
643 | + * bytes. | ||
644 | + */ | ||
645 | + for (size_t i = 0; i < count; ++i) { | ||
646 | + emc_write_rx_desc(qts, desc + i, desc_addr + i * sizeof(*desc)); | ||
647 | + } | ||
648 | + | ||
649 | + /* Trigger receiving the packet. */ | ||
650 | + /* The module must be reset before changing RXDLSA. */ | ||
651 | + g_assert(emc_soft_reset(qts, mod)); | ||
652 | + emc_write(qts, mod, REG_RXDLSA, desc_addr); | ||
653 | + emc_write(qts, mod, REG_MIEN, REG_MIEN_ENRXGD | mien_flags); | ||
654 | + | ||
655 | + /* | ||
656 | + * We don't know what the device's macaddr is, so just accept all | ||
657 | + * unicast packets (AUP). | ||
658 | + */ | ||
659 | + emc_write(qts, mod, REG_CAMCMR, REG_CAMCMR_AUP); | ||
660 | + emc_write(qts, mod, REG_CAMEN, 1 << 0); | ||
661 | + { | ||
662 | + uint32_t mcmdr = emc_read(qts, mod, REG_MCMDR); | ||
663 | + mcmdr |= REG_MCMDR_RXON | mcmdr_flags; | ||
664 | + emc_write(qts, mod, REG_MCMDR, mcmdr); | ||
665 | + } | ||
666 | + | ||
667 | + /* Prod the device to accept a packet. */ | ||
668 | + emc_write(qts, mod, REG_RSDR, 1); | ||
669 | +} | ||
670 | + | ||
671 | +static void emc_recv_verify(QTestState *qts, const EMCModule *mod, int fd, | ||
672 | + bool with_irq) | ||
673 | +{ | ||
674 | + NPCM7xxEMCRxDesc desc[NUM_RX_DESCRIPTORS]; | ||
675 | + uint32_t desc_addr = DESC_ADDR; | ||
676 | + uint32_t data_addr = DATA_ADDR; | ||
677 | + int ret; | ||
678 | + uint32_t expected_mask, expected_value; | ||
679 | + NPCM7xxEMCRxDesc result_desc; | ||
680 | + | ||
681 | + /* Prepare test data buffer. */ | ||
682 | + const char test[RX_DATA_LEN] = "TEST"; | ||
683 | + int len = htonl(sizeof(test)); | ||
684 | + const struct iovec iov[] = { | ||
685 | + { | ||
686 | + .iov_base = &len, | ||
687 | + .iov_len = sizeof(len), | ||
688 | + },{ | ||
689 | + .iov_base = (char *) test, | ||
690 | + .iov_len = sizeof(test), | ||
691 | + }, | ||
692 | + }; | ||
693 | + | ||
694 | + /* | ||
695 | + * Reset the device BEFORE sending a test packet, otherwise the packet | ||
696 | + * may get swallowed by an active device of an earlier test. | ||
697 | + */ | ||
698 | + init_rx_desc(&desc[0], NUM_RX_DESCRIPTORS, desc_addr, data_addr); | ||
699 | + enable_rx(qts, mod, &desc[0], NUM_RX_DESCRIPTORS, desc_addr, | ||
700 | + with_irq ? REG_MIEN_ENRXINTR : 0, 0); | ||
701 | + | ||
702 | + /* Send test packet to device's socket. */ | ||
703 | + ret = iov_send(fd, iov, 2, 0, sizeof(len) + sizeof(test)); | ||
704 | + g_assert_cmpint(ret, == , sizeof(test) + sizeof(len)); | ||
705 | + | ||
706 | + /* Wait for RX interrupt. */ | ||
707 | + if (with_irq) { | ||
708 | + g_assert_true(emc_wait_irq(qts, mod, RX_STEP_COUNT, /*is_tx=*/false)); | ||
709 | + } else { | ||
710 | + g_assert_true(emc_wait_mista(qts, mod, RX_STEP_COUNT, REG_MISTA_RXGD)); | ||
711 | + } | ||
712 | + | ||
713 | + g_assert_cmphex(emc_read(qts, mod, REG_CRXDSA), ==, | ||
714 | + desc_addr + sizeof(desc[0])); | ||
715 | + | ||
716 | + expected_mask = 0xffff; | ||
717 | + expected_value = (REG_MISTA_DENI | | ||
718 | + REG_MISTA_RXGD | | ||
719 | + REG_MISTA_RXINTR); | ||
720 | + g_assert_cmphex((emc_read(qts, mod, REG_MISTA) & expected_mask), | ||
721 | + ==, expected_value); | ||
722 | + | ||
723 | + /* Read the descriptor back. */ | ||
724 | + emc_read_rx_desc(qts, desc_addr, &result_desc); | ||
725 | + /* Descriptor should be owned by cpu now. */ | ||
726 | + g_assert((result_desc.status_and_length & RX_DESC_STATUS_OWNER_MASK) == 0); | ||
727 | + /* Test the status bits, ignoring the length field. */ | ||
728 | + expected_mask = 0xffff << 16; | ||
729 | + expected_value = RX_DESC_STATUS_RXGD; | ||
730 | + if (with_irq) { | ||
731 | + expected_value |= RX_DESC_STATUS_RXINTR; | ||
732 | + } | ||
733 | + g_assert_cmphex((result_desc.status_and_length & expected_mask), ==, | ||
734 | + expected_value); | ||
735 | + g_assert_cmpint(RX_DESC_PKT_LEN(result_desc.status_and_length), ==, | ||
736 | + RX_DATA_LEN + CRC_LENGTH); | ||
737 | + | ||
738 | + { | ||
739 | + char buffer[RX_DATA_LEN]; | ||
740 | + qtest_memread(qts, data_addr, buffer, sizeof(buffer)); | ||
741 | + g_assert_cmpstr(buffer, == , "TEST"); | ||
742 | + } | ||
743 | +} | ||
744 | + | ||
745 | +static void emc_test_ptle(QTestState *qts, const EMCModule *mod, int fd) | ||
746 | +{ | ||
747 | + NPCM7xxEMCRxDesc desc[NUM_RX_DESCRIPTORS]; | ||
748 | + uint32_t desc_addr = DESC_ADDR; | ||
749 | + uint32_t data_addr = DATA_ADDR; | ||
750 | + int ret; | ||
751 | + NPCM7xxEMCRxDesc result_desc; | ||
752 | + uint32_t expected_mask, expected_value; | ||
753 | + | ||
754 | + /* Prepare test data buffer. */ | ||
755 | +#define PTLE_DATA_LEN 1600 | ||
756 | + char test_data[PTLE_DATA_LEN]; | ||
757 | + int len = htonl(sizeof(test_data)); | ||
758 | + const struct iovec iov[] = { | ||
759 | + { | ||
760 | + .iov_base = &len, | ||
761 | + .iov_len = sizeof(len), | ||
762 | + },{ | ||
763 | + .iov_base = (char *) test_data, | ||
764 | + .iov_len = sizeof(test_data), | ||
765 | + }, | ||
766 | + }; | ||
767 | + memset(test_data, 42, sizeof(test_data)); | ||
768 | + | ||
769 | + /* | ||
770 | + * Reset the device BEFORE sending a test packet, otherwise the packet | ||
771 | + * may get swallowed by an active device of an earlier test. | ||
772 | + */ | ||
773 | + init_rx_desc(&desc[0], NUM_RX_DESCRIPTORS, desc_addr, data_addr); | ||
774 | + enable_rx(qts, mod, &desc[0], NUM_RX_DESCRIPTORS, desc_addr, | ||
775 | + REG_MIEN_ENRXINTR, REG_MCMDR_ALP); | ||
776 | + | ||
777 | + /* Send test packet to device's socket. */ | ||
778 | + ret = iov_send(fd, iov, 2, 0, sizeof(len) + sizeof(test_data)); | ||
779 | + g_assert_cmpint(ret, == , sizeof(test_data) + sizeof(len)); | ||
780 | + | ||
781 | + /* Wait for RX interrupt. */ | ||
782 | + g_assert_true(emc_wait_irq(qts, mod, RX_STEP_COUNT, /*is_tx=*/false)); | ||
783 | + | ||
784 | + /* Read the descriptor back. */ | ||
785 | + emc_read_rx_desc(qts, desc_addr, &result_desc); | ||
786 | + /* Descriptor should be owned by cpu now. */ | ||
787 | + g_assert((result_desc.status_and_length & RX_DESC_STATUS_OWNER_MASK) == 0); | ||
788 | + /* Test the status bits, ignoring the length field. */ | ||
789 | + expected_mask = 0xffff << 16; | ||
790 | + expected_value = (RX_DESC_STATUS_RXGD | | ||
791 | + RX_DESC_STATUS_PTLE | | ||
792 | + RX_DESC_STATUS_RXINTR); | ||
793 | + g_assert_cmphex((result_desc.status_and_length & expected_mask), ==, | ||
794 | + expected_value); | ||
795 | + g_assert_cmpint(RX_DESC_PKT_LEN(result_desc.status_and_length), ==, | ||
796 | + PTLE_DATA_LEN + CRC_LENGTH); | ||
797 | + | ||
798 | + { | ||
799 | + char buffer[PTLE_DATA_LEN]; | ||
800 | + qtest_memread(qts, data_addr, buffer, sizeof(buffer)); | ||
801 | + g_assert(memcmp(buffer, test_data, PTLE_DATA_LEN) == 0); | ||
802 | + } | ||
803 | +} | ||
804 | + | ||
805 | +static void test_tx(gconstpointer test_data) | ||
806 | +{ | ||
807 | + const TestData *td = test_data; | ||
808 | + GString *cmd_line = g_string_new("-machine quanta-gsj"); | ||
809 | + int *test_sockets = packet_test_init(emc_module_index(td->module), | ||
810 | + cmd_line); | ||
811 | + QTestState *qts = qtest_init(cmd_line->str); | ||
812 | + | ||
813 | + /* | ||
814 | + * TODO: For pedantic correctness test_sockets[0] should be closed after | ||
815 | + * the fork and before the exec, but that will require some harness | ||
816 | + * improvements. | ||
817 | + */ | ||
818 | + close(test_sockets[1]); | ||
819 | + /* Defensive programming */ | ||
820 | + test_sockets[1] = -1; | ||
821 | + | ||
822 | + qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); | ||
823 | + | ||
824 | + emc_send_verify(qts, td->module, test_sockets[0], /*with_irq=*/false); | ||
825 | + emc_send_verify(qts, td->module, test_sockets[0], /*with_irq=*/true); | ||
826 | + | ||
827 | + qtest_quit(qts); | ||
828 | +} | ||
829 | + | ||
830 | +static void test_rx(gconstpointer test_data) | ||
831 | +{ | ||
832 | + const TestData *td = test_data; | ||
833 | + GString *cmd_line = g_string_new("-machine quanta-gsj"); | ||
834 | + int *test_sockets = packet_test_init(emc_module_index(td->module), | ||
835 | + cmd_line); | ||
836 | + QTestState *qts = qtest_init(cmd_line->str); | ||
837 | + | ||
838 | + /* | ||
839 | + * TODO: For pedantic correctness test_sockets[0] should be closed after | ||
840 | + * the fork and before the exec, but that will require some harness | ||
841 | + * improvements. | ||
842 | + */ | ||
843 | + close(test_sockets[1]); | ||
844 | + /* Defensive programming */ | ||
845 | + test_sockets[1] = -1; | ||
846 | + | ||
847 | + qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); | ||
848 | + | ||
849 | + emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/false); | ||
850 | + emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/true); | ||
851 | + emc_test_ptle(qts, td->module, test_sockets[0]); | ||
852 | + | ||
853 | + qtest_quit(qts); | ||
854 | +} | ||
855 | + | ||
856 | +static void emc_add_test(const char *name, const TestData* td, | ||
857 | + GTestDataFunc fn) | ||
858 | +{ | ||
859 | + g_autofree char *full_name = g_strdup_printf( | ||
860 | + "npcm7xx_emc/emc[%d]/%s", emc_module_index(td->module), name); | ||
861 | + qtest_add_data_func(full_name, td, fn); | ||
862 | +} | ||
863 | +#define add_test(name, td) emc_add_test(#name, td, test_##name) | ||
864 | + | ||
865 | +int main(int argc, char **argv) | ||
866 | +{ | ||
867 | + TestData test_data_list[ARRAY_SIZE(emc_module_list)]; | ||
868 | + | ||
869 | + g_test_init(&argc, &argv, NULL); | ||
870 | + | ||
871 | + for (int i = 0; i < ARRAY_SIZE(emc_module_list); ++i) { | ||
872 | + TestData *td = &test_data_list[i]; | ||
873 | + | ||
874 | + td->module = &emc_module_list[i]; | ||
875 | + | ||
876 | + add_test(init, td); | ||
877 | + add_test(tx, td); | ||
878 | + add_test(rx, td); | ||
879 | + } | ||
880 | + | ||
881 | + return g_test_run(); | ||
882 | +} | ||
883 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
884 | index XXXXXXX..XXXXXXX 100644 | ||
885 | --- a/tests/qtest/meson.build | ||
886 | +++ b/tests/qtest/meson.build | ||
887 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ | ||
888 | 'npcm7xx_rng-test', | ||
889 | 'npcm7xx_smbus-test', | ||
890 | 'npcm7xx_timer-test', | ||
891 | - 'npcm7xx_watchdog_timer-test'] | ||
892 | + 'npcm7xx_watchdog_timer-test'] + \ | ||
893 | + (slirp.found() ? ['npcm7xx_emc-test'] : []) | ||
894 | qtests_arm = \ | ||
895 | (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ | ||
896 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ | ||
897 | -- | 150 | -- |
898 | 2.20.1 | 151 | 2.34.1 |
899 | 152 | ||
900 | 153 | diff view generated by jsdifflib |
1 | From: Doug Evans <dje@google.com> | 1 | Move the feature test functions that test ID_AA64ISAR* fields |
---|---|---|---|
2 | together. | ||
2 | 3 | ||
3 | This is a 10/100 ethernet device that has several features. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Only the ones needed by the Linux driver have been implemented. | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | See npcm7xx_emc.c for a list of unimplemented features. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20231024163510.2972081-5-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/cpu-features.h | 70 +++++++++++++++++++-------------------- | ||
10 | 1 file changed, 35 insertions(+), 35 deletions(-) | ||
6 | 11 | ||
7 | Reviewed-by: Hao Wu <wuhaotsh@google.com> | 12 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
8 | Reviewed-by: Avi Fishman <avi.fishman@nuvoton.com> | 13 | index XXXXXXX..XXXXXXX 100644 |
9 | Signed-off-by: Doug Evans <dje@google.com> | 14 | --- a/target/arm/cpu-features.h |
10 | Message-id: 20210218212453.831406-2-dje@google.com | 15 | +++ b/target/arm/cpu-features.h |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_rndr(const ARMISARegisters *id) |
12 | --- | 17 | return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, RNDR) != 0; |
13 | include/hw/net/npcm7xx_emc.h | 286 ++++++++++++ | 18 | } |
14 | hw/net/npcm7xx_emc.c | 857 +++++++++++++++++++++++++++++++++++ | 19 | |
15 | hw/net/meson.build | 1 + | 20 | +static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) |
16 | hw/net/trace-events | 17 + | ||
17 | 4 files changed, 1161 insertions(+) | ||
18 | create mode 100644 include/hw/net/npcm7xx_emc.h | ||
19 | create mode 100644 hw/net/npcm7xx_emc.c | ||
20 | |||
21 | diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h | ||
22 | new file mode 100644 | ||
23 | index XXXXXXX..XXXXXXX | ||
24 | --- /dev/null | ||
25 | +++ b/include/hw/net/npcm7xx_emc.h | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | +/* | ||
28 | + * Nuvoton NPCM7xx EMC Module | ||
29 | + * | ||
30 | + * Copyright 2020 Google LLC | ||
31 | + * | ||
32 | + * This program is free software; you can redistribute it and/or modify it | ||
33 | + * under the terms of the GNU General Public License as published by the | ||
34 | + * Free Software Foundation; either version 2 of the License, or | ||
35 | + * (at your option) any later version. | ||
36 | + * | ||
37 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
38 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
39 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
40 | + * for more details. | ||
41 | + */ | ||
42 | + | ||
43 | +#ifndef NPCM7XX_EMC_H | ||
44 | +#define NPCM7XX_EMC_H | ||
45 | + | ||
46 | +#include "hw/irq.h" | ||
47 | +#include "hw/sysbus.h" | ||
48 | +#include "net/net.h" | ||
49 | + | ||
50 | +/* 32-bit register indices. */ | ||
51 | +enum NPCM7xxPWMRegister { | ||
52 | + /* Control registers. */ | ||
53 | + REG_CAMCMR, | ||
54 | + REG_CAMEN, | ||
55 | + | ||
56 | + /* There are 16 CAMn[ML] registers. */ | ||
57 | + REG_CAMM_BASE, | ||
58 | + REG_CAML_BASE, | ||
59 | + REG_CAMML_LAST = 0x21, | ||
60 | + | ||
61 | + REG_TXDLSA = 0x22, | ||
62 | + REG_RXDLSA, | ||
63 | + REG_MCMDR, | ||
64 | + REG_MIID, | ||
65 | + REG_MIIDA, | ||
66 | + REG_FFTCR, | ||
67 | + REG_TSDR, | ||
68 | + REG_RSDR, | ||
69 | + REG_DMARFC, | ||
70 | + REG_MIEN, | ||
71 | + | ||
72 | + /* Status registers. */ | ||
73 | + REG_MISTA, | ||
74 | + REG_MGSTA, | ||
75 | + REG_MPCNT, | ||
76 | + REG_MRPC, | ||
77 | + REG_MRPCC, | ||
78 | + REG_MREPC, | ||
79 | + REG_DMARFS, | ||
80 | + REG_CTXDSA, | ||
81 | + REG_CTXBSA, | ||
82 | + REG_CRXDSA, | ||
83 | + REG_CRXBSA, | ||
84 | + | ||
85 | + NPCM7XX_NUM_EMC_REGS, | ||
86 | +}; | ||
87 | + | ||
88 | +/* REG_CAMCMR fields */ | ||
89 | +/* Enable CAM Compare */ | ||
90 | +#define REG_CAMCMR_ECMP (1 << 4) | ||
91 | +/* Complement CAM Compare */ | ||
92 | +#define REG_CAMCMR_CCAM (1 << 3) | ||
93 | +/* Accept Broadcast Packet */ | ||
94 | +#define REG_CAMCMR_ABP (1 << 2) | ||
95 | +/* Accept Multicast Packet */ | ||
96 | +#define REG_CAMCMR_AMP (1 << 1) | ||
97 | +/* Accept Unicast Packet */ | ||
98 | +#define REG_CAMCMR_AUP (1 << 0) | ||
99 | + | ||
100 | +/* REG_MCMDR fields */ | ||
101 | +/* Software Reset */ | ||
102 | +#define REG_MCMDR_SWR (1 << 24) | ||
103 | +/* Internal Loopback Select */ | ||
104 | +#define REG_MCMDR_LBK (1 << 21) | ||
105 | +/* Operation Mode Select */ | ||
106 | +#define REG_MCMDR_OPMOD (1 << 20) | ||
107 | +/* Enable MDC Clock Generation */ | ||
108 | +#define REG_MCMDR_ENMDC (1 << 19) | ||
109 | +/* Full-Duplex Mode Select */ | ||
110 | +#define REG_MCMDR_FDUP (1 << 18) | ||
111 | +/* Enable SQE Checking */ | ||
112 | +#define REG_MCMDR_ENSEQ (1 << 17) | ||
113 | +/* Send PAUSE Frame */ | ||
114 | +#define REG_MCMDR_SDPZ (1 << 16) | ||
115 | +/* No Defer */ | ||
116 | +#define REG_MCMDR_NDEF (1 << 9) | ||
117 | +/* Frame Transmission On */ | ||
118 | +#define REG_MCMDR_TXON (1 << 8) | ||
119 | +/* Strip CRC Checksum */ | ||
120 | +#define REG_MCMDR_SPCRC (1 << 5) | ||
121 | +/* Accept CRC Error Packet */ | ||
122 | +#define REG_MCMDR_AEP (1 << 4) | ||
123 | +/* Accept Control Packet */ | ||
124 | +#define REG_MCMDR_ACP (1 << 3) | ||
125 | +/* Accept Runt Packet */ | ||
126 | +#define REG_MCMDR_ARP (1 << 2) | ||
127 | +/* Accept Long Packet */ | ||
128 | +#define REG_MCMDR_ALP (1 << 1) | ||
129 | +/* Frame Reception On */ | ||
130 | +#define REG_MCMDR_RXON (1 << 0) | ||
131 | + | ||
132 | +/* REG_MIEN fields */ | ||
133 | +/* Enable Transmit Descriptor Unavailable Interrupt */ | ||
134 | +#define REG_MIEN_ENTDU (1 << 23) | ||
135 | +/* Enable Transmit Completion Interrupt */ | ||
136 | +#define REG_MIEN_ENTXCP (1 << 18) | ||
137 | +/* Enable Transmit Interrupt */ | ||
138 | +#define REG_MIEN_ENTXINTR (1 << 16) | ||
139 | +/* Enable Receive Descriptor Unavailable Interrupt */ | ||
140 | +#define REG_MIEN_ENRDU (1 << 10) | ||
141 | +/* Enable Receive Good Interrupt */ | ||
142 | +#define REG_MIEN_ENRXGD (1 << 4) | ||
143 | +/* Enable Receive Interrupt */ | ||
144 | +#define REG_MIEN_ENRXINTR (1 << 0) | ||
145 | + | ||
146 | +/* REG_MISTA fields */ | ||
147 | +/* TODO: Add error fields and support simulated errors? */ | ||
148 | +/* Transmit Bus Error Interrupt */ | ||
149 | +#define REG_MISTA_TXBERR (1 << 24) | ||
150 | +/* Transmit Descriptor Unavailable Interrupt */ | ||
151 | +#define REG_MISTA_TDU (1 << 23) | ||
152 | +/* Transmit Completion Interrupt */ | ||
153 | +#define REG_MISTA_TXCP (1 << 18) | ||
154 | +/* Transmit Interrupt */ | ||
155 | +#define REG_MISTA_TXINTR (1 << 16) | ||
156 | +/* Receive Bus Error Interrupt */ | ||
157 | +#define REG_MISTA_RXBERR (1 << 11) | ||
158 | +/* Receive Descriptor Unavailable Interrupt */ | ||
159 | +#define REG_MISTA_RDU (1 << 10) | ||
160 | +/* DMA Early Notification Interrupt */ | ||
161 | +#define REG_MISTA_DENI (1 << 9) | ||
162 | +/* Maximum Frame Length Interrupt */ | ||
163 | +#define REG_MISTA_DFOI (1 << 8) | ||
164 | +/* Receive Good Interrupt */ | ||
165 | +#define REG_MISTA_RXGD (1 << 4) | ||
166 | +/* Packet Too Long Interrupt */ | ||
167 | +#define REG_MISTA_PTLE (1 << 3) | ||
168 | +/* Receive Interrupt */ | ||
169 | +#define REG_MISTA_RXINTR (1 << 0) | ||
170 | + | ||
171 | +/* REG_MGSTA fields */ | ||
172 | +/* Transmission Halted */ | ||
173 | +#define REG_MGSTA_TXHA (1 << 11) | ||
174 | +/* Receive Halted */ | ||
175 | +#define REG_MGSTA_RXHA (1 << 11) | ||
176 | + | ||
177 | +/* REG_DMARFC fields */ | ||
178 | +/* Maximum Receive Frame Length */ | ||
179 | +#define REG_DMARFC_RXMS(word) extract32((word), 0, 16) | ||
180 | + | ||
181 | +/* REG MIIDA fields */ | ||
182 | +/* Busy Bit */ | ||
183 | +#define REG_MIIDA_BUSY (1 << 17) | ||
184 | + | ||
185 | +/* Transmit and receive descriptors */ | ||
186 | +typedef struct NPCM7xxEMCTxDesc NPCM7xxEMCTxDesc; | ||
187 | +typedef struct NPCM7xxEMCRxDesc NPCM7xxEMCRxDesc; | ||
188 | + | ||
189 | +struct NPCM7xxEMCTxDesc { | ||
190 | + uint32_t flags; | ||
191 | + uint32_t txbsa; | ||
192 | + uint32_t status_and_length; | ||
193 | + uint32_t ntxdsa; | ||
194 | +}; | ||
195 | + | ||
196 | +struct NPCM7xxEMCRxDesc { | ||
197 | + uint32_t status_and_length; | ||
198 | + uint32_t rxbsa; | ||
199 | + uint32_t reserved; | ||
200 | + uint32_t nrxdsa; | ||
201 | +}; | ||
202 | + | ||
203 | +/* NPCM7xxEMCTxDesc.flags values */ | ||
204 | +/* Owner: 0 = cpu, 1 = emc */ | ||
205 | +#define TX_DESC_FLAG_OWNER_MASK (1 << 31) | ||
206 | +/* Transmit interrupt enable */ | ||
207 | +#define TX_DESC_FLAG_INTEN (1 << 2) | ||
208 | +/* CRC append */ | ||
209 | +#define TX_DESC_FLAG_CRCAPP (1 << 1) | ||
210 | +/* Padding enable */ | ||
211 | +#define TX_DESC_FLAG_PADEN (1 << 0) | ||
212 | + | ||
213 | +/* NPCM7xxEMCTxDesc.status_and_length values */ | ||
214 | +/* Collision count */ | ||
215 | +#define TX_DESC_STATUS_CCNT_SHIFT 28 | ||
216 | +#define TX_DESC_STATUS_CCNT_BITSIZE 4 | ||
217 | +/* SQE error */ | ||
218 | +#define TX_DESC_STATUS_SQE (1 << 26) | ||
219 | +/* Transmission paused */ | ||
220 | +#define TX_DESC_STATUS_PAU (1 << 25) | ||
221 | +/* P transmission halted */ | ||
222 | +#define TX_DESC_STATUS_TXHA (1 << 24) | ||
223 | +/* Late collision */ | ||
224 | +#define TX_DESC_STATUS_LC (1 << 23) | ||
225 | +/* Transmission abort */ | ||
226 | +#define TX_DESC_STATUS_TXABT (1 << 22) | ||
227 | +/* No carrier sense */ | ||
228 | +#define TX_DESC_STATUS_NCS (1 << 21) | ||
229 | +/* Defer exceed */ | ||
230 | +#define TX_DESC_STATUS_EXDEF (1 << 20) | ||
231 | +/* Transmission complete */ | ||
232 | +#define TX_DESC_STATUS_TXCP (1 << 19) | ||
233 | +/* Transmission deferred */ | ||
234 | +#define TX_DESC_STATUS_DEF (1 << 17) | ||
235 | +/* Transmit interrupt */ | ||
236 | +#define TX_DESC_STATUS_TXINTR (1 << 16) | ||
237 | + | ||
238 | +#define TX_DESC_PKT_LEN(word) extract32((word), 0, 16) | ||
239 | + | ||
240 | +/* Transmit buffer start address */ | ||
241 | +#define TX_DESC_TXBSA(word) ((uint32_t) (word) & ~3u) | ||
242 | + | ||
243 | +/* Next transmit descriptor start address */ | ||
244 | +#define TX_DESC_NTXDSA(word) ((uint32_t) (word) & ~3u) | ||
245 | + | ||
246 | +/* NPCM7xxEMCRxDesc.status_and_length values */ | ||
247 | +/* Owner: 0b00 = cpu, 0b01 = undefined, 0b10 = emc, 0b11 = undefined */ | ||
248 | +#define RX_DESC_STATUS_OWNER_SHIFT 30 | ||
249 | +#define RX_DESC_STATUS_OWNER_BITSIZE 2 | ||
250 | +#define RX_DESC_STATUS_OWNER_MASK (3 << RX_DESC_STATUS_OWNER_SHIFT) | ||
251 | +/* Runt packet */ | ||
252 | +#define RX_DESC_STATUS_RP (1 << 22) | ||
253 | +/* Alignment error */ | ||
254 | +#define RX_DESC_STATUS_ALIE (1 << 21) | ||
255 | +/* Frame reception complete */ | ||
256 | +#define RX_DESC_STATUS_RXGD (1 << 20) | ||
257 | +/* Packet too long */ | ||
258 | +#define RX_DESC_STATUS_PTLE (1 << 19) | ||
259 | +/* CRC error */ | ||
260 | +#define RX_DESC_STATUS_CRCE (1 << 17) | ||
261 | +/* Receive interrupt */ | ||
262 | +#define RX_DESC_STATUS_RXINTR (1 << 16) | ||
263 | + | ||
264 | +#define RX_DESC_PKT_LEN(word) extract32((word), 0, 16) | ||
265 | + | ||
266 | +/* Receive buffer start address */ | ||
267 | +#define RX_DESC_RXBSA(word) ((uint32_t) (word) & ~3u) | ||
268 | + | ||
269 | +/* Next receive descriptor start address */ | ||
270 | +#define RX_DESC_NRXDSA(word) ((uint32_t) (word) & ~3u) | ||
271 | + | ||
272 | +/* Minimum packet length, when TX_DESC_FLAG_PADEN is set. */ | ||
273 | +#define MIN_PACKET_LENGTH 64 | ||
274 | + | ||
275 | +struct NPCM7xxEMCState { | ||
276 | + /*< private >*/ | ||
277 | + SysBusDevice parent; | ||
278 | + /*< public >*/ | ||
279 | + | ||
280 | + MemoryRegion iomem; | ||
281 | + | ||
282 | + qemu_irq tx_irq; | ||
283 | + qemu_irq rx_irq; | ||
284 | + | ||
285 | + NICState *nic; | ||
286 | + NICConf conf; | ||
287 | + | ||
288 | + /* 0 or 1, for log messages */ | ||
289 | + uint8_t emc_num; | ||
290 | + | ||
291 | + uint32_t regs[NPCM7XX_NUM_EMC_REGS]; | ||
292 | + | ||
293 | + /* | ||
294 | + * tx is active. Set to true by TSDR and then switches off when out of | ||
295 | + * descriptors. If the TXON bit in REG_MCMDR is off then this is off. | ||
296 | + */ | ||
297 | + bool tx_active; | ||
298 | + | ||
299 | + /* | ||
300 | + * rx is active. Set to true by RSDR and then switches off when out of | ||
301 | + * descriptors. If the RXON bit in REG_MCMDR is off then this is off. | ||
302 | + */ | ||
303 | + bool rx_active; | ||
304 | +}; | ||
305 | + | ||
306 | +typedef struct NPCM7xxEMCState NPCM7xxEMCState; | ||
307 | + | ||
308 | +#define TYPE_NPCM7XX_EMC "npcm7xx-emc" | ||
309 | +#define NPCM7XX_EMC(obj) \ | ||
310 | + OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC) | ||
311 | + | ||
312 | +#endif /* NPCM7XX_EMC_H */ | ||
313 | diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c | ||
314 | new file mode 100644 | ||
315 | index XXXXXXX..XXXXXXX | ||
316 | --- /dev/null | ||
317 | +++ b/hw/net/npcm7xx_emc.c | ||
318 | @@ -XXX,XX +XXX,XX @@ | ||
319 | +/* | ||
320 | + * Nuvoton NPCM7xx EMC Module | ||
321 | + * | ||
322 | + * Copyright 2020 Google LLC | ||
323 | + * | ||
324 | + * This program is free software; you can redistribute it and/or modify it | ||
325 | + * under the terms of the GNU General Public License as published by the | ||
326 | + * Free Software Foundation; either version 2 of the License, or | ||
327 | + * (at your option) any later version. | ||
328 | + * | ||
329 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
330 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
331 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
332 | + * for more details. | ||
333 | + * | ||
334 | + * Unsupported/unimplemented features: | ||
335 | + * - MCMDR.FDUP (full duplex) is ignored, half duplex is not supported | ||
336 | + * - Only CAM0 is supported, CAM[1-15] are not | ||
337 | + * - writes to CAMEN.[1-15] are ignored, these bits always read as zeroes | ||
338 | + * - MII is not implemented, MIIDA.BUSY and MIID always return zero | ||
339 | + * - MCMDR.LBK is not implemented | ||
340 | + * - MCMDR.{OPMOD,ENSQE,AEP,ARP} are not supported | ||
341 | + * - H/W FIFOs are not supported, MCMDR.FFTCR is ignored | ||
342 | + * - MGSTA.SQE is not supported | ||
343 | + * - pause and control frames are not implemented | ||
344 | + * - MGSTA.CCNT is not supported | ||
345 | + * - MPCNT, DMARFS are not implemented | ||
346 | + */ | ||
347 | + | ||
348 | +#include "qemu/osdep.h" | ||
349 | + | ||
350 | +/* For crc32 */ | ||
351 | +#include <zlib.h> | ||
352 | + | ||
353 | +#include "qemu-common.h" | ||
354 | +#include "hw/irq.h" | ||
355 | +#include "hw/qdev-clock.h" | ||
356 | +#include "hw/qdev-properties.h" | ||
357 | +#include "hw/net/npcm7xx_emc.h" | ||
358 | +#include "net/eth.h" | ||
359 | +#include "migration/vmstate.h" | ||
360 | +#include "qemu/bitops.h" | ||
361 | +#include "qemu/error-report.h" | ||
362 | +#include "qemu/log.h" | ||
363 | +#include "qemu/module.h" | ||
364 | +#include "qemu/units.h" | ||
365 | +#include "sysemu/dma.h" | ||
366 | +#include "trace.h" | ||
367 | + | ||
368 | +#define CRC_LENGTH 4 | ||
369 | + | ||
370 | +/* | ||
371 | + * The maximum size of a (layer 2) ethernet frame as defined by 802.3. | ||
372 | + * 1518 = 6(dest macaddr) + 6(src macaddr) + 2(proto) + 4(crc) + 1500(payload) | ||
373 | + * This does not include an additional 4 for the vlan field (802.1q). | ||
374 | + */ | ||
375 | +#define MAX_ETH_FRAME_SIZE 1518 | ||
376 | + | ||
377 | +static const char *emc_reg_name(int regno) | ||
378 | +{ | 21 | +{ |
379 | +#define REG(name) case REG_ ## name: return #name; | 22 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; |
380 | + switch (regno) { | ||
381 | + REG(CAMCMR) | ||
382 | + REG(CAMEN) | ||
383 | + REG(TXDLSA) | ||
384 | + REG(RXDLSA) | ||
385 | + REG(MCMDR) | ||
386 | + REG(MIID) | ||
387 | + REG(MIIDA) | ||
388 | + REG(FFTCR) | ||
389 | + REG(TSDR) | ||
390 | + REG(RSDR) | ||
391 | + REG(DMARFC) | ||
392 | + REG(MIEN) | ||
393 | + REG(MISTA) | ||
394 | + REG(MGSTA) | ||
395 | + REG(MPCNT) | ||
396 | + REG(MRPC) | ||
397 | + REG(MRPCC) | ||
398 | + REG(MREPC) | ||
399 | + REG(DMARFS) | ||
400 | + REG(CTXDSA) | ||
401 | + REG(CTXBSA) | ||
402 | + REG(CRXDSA) | ||
403 | + REG(CRXBSA) | ||
404 | + case REG_CAMM_BASE + 0: return "CAM0M"; | ||
405 | + case REG_CAML_BASE + 0: return "CAM0L"; | ||
406 | + case REG_CAMM_BASE + 2 ... REG_CAMML_LAST: | ||
407 | + /* Only CAM0 is supported, fold the others into something simple. */ | ||
408 | + if (regno & 1) { | ||
409 | + return "CAM<n>L"; | ||
410 | + } else { | ||
411 | + return "CAM<n>M"; | ||
412 | + } | ||
413 | + default: return "UNKNOWN"; | ||
414 | + } | ||
415 | +#undef REG | ||
416 | +} | 23 | +} |
417 | + | 24 | + |
418 | +static void emc_reset(NPCM7xxEMCState *emc) | 25 | +static inline bool isar_feature_aa64_tlbios(const ARMISARegisters *id) |
419 | +{ | 26 | +{ |
420 | + trace_npcm7xx_emc_reset(emc->emc_num); | 27 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) != 0; |
421 | + | ||
422 | + memset(&emc->regs[0], 0, sizeof(emc->regs)); | ||
423 | + | ||
424 | + /* These regs have non-zero reset values. */ | ||
425 | + emc->regs[REG_TXDLSA] = 0xfffffffc; | ||
426 | + emc->regs[REG_RXDLSA] = 0xfffffffc; | ||
427 | + emc->regs[REG_MIIDA] = 0x00900000; | ||
428 | + emc->regs[REG_FFTCR] = 0x0101; | ||
429 | + emc->regs[REG_DMARFC] = 0x0800; | ||
430 | + emc->regs[REG_MPCNT] = 0x7fff; | ||
431 | + | ||
432 | + emc->tx_active = false; | ||
433 | + emc->rx_active = false; | ||
434 | +} | 28 | +} |
435 | + | 29 | + |
436 | +static void npcm7xx_emc_reset(DeviceState *dev) | 30 | static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) |
31 | { | ||
32 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; | ||
33 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pauth_qarma3(const ARMISARegisters *id) | ||
34 | return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) != 0; | ||
35 | } | ||
36 | |||
37 | -static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) | ||
38 | -{ | ||
39 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; | ||
40 | -} | ||
41 | - | ||
42 | -static inline bool isar_feature_aa64_tlbios(const ARMISARegisters *id) | ||
43 | -{ | ||
44 | - return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) != 0; | ||
45 | -} | ||
46 | - | ||
47 | static inline bool isar_feature_aa64_sb(const ARMISARegisters *id) | ||
48 | { | ||
49 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0; | ||
50 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_bf16(const ARMISARegisters *id) | ||
51 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, BF16) != 0; | ||
52 | } | ||
53 | |||
54 | +static inline bool isar_feature_aa64_rcpc_8_3(const ARMISARegisters *id) | ||
437 | +{ | 55 | +{ |
438 | + NPCM7xxEMCState *emc = NPCM7XX_EMC(dev); | 56 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) != 0; |
439 | + emc_reset(emc); | ||
440 | +} | 57 | +} |
441 | + | 58 | + |
442 | +static void emc_soft_reset(NPCM7xxEMCState *emc) | 59 | +static inline bool isar_feature_aa64_rcpc_8_4(const ARMISARegisters *id) |
443 | +{ | 60 | +{ |
444 | + /* | 61 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) >= 2; |
445 | + * The docs say at least MCMDR.{LBK,OPMOD} bits are not changed during a | ||
446 | + * soft reset, but does not go into further detail. For now, KISS. | ||
447 | + */ | ||
448 | + uint32_t mcmdr = emc->regs[REG_MCMDR]; | ||
449 | + emc_reset(emc); | ||
450 | + emc->regs[REG_MCMDR] = mcmdr & (REG_MCMDR_LBK | REG_MCMDR_OPMOD); | ||
451 | + | ||
452 | + qemu_set_irq(emc->tx_irq, 0); | ||
453 | + qemu_set_irq(emc->rx_irq, 0); | ||
454 | +} | 62 | +} |
455 | + | 63 | + |
456 | +static void emc_set_link(NetClientState *nc) | 64 | +static inline bool isar_feature_aa64_i8mm(const ARMISARegisters *id) |
457 | +{ | 65 | +{ |
458 | + /* Nothing to do yet. */ | 66 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, I8MM) != 0; |
459 | +} | 67 | +} |
460 | + | 68 | + |
461 | +/* MISTA.TXINTR is the union of the individual bits with their enables. */ | 69 | +static inline bool isar_feature_aa64_hbc(const ARMISARegisters *id) |
462 | +static void emc_update_mista_txintr(NPCM7xxEMCState *emc) | ||
463 | +{ | 70 | +{ |
464 | + /* Only look at the bits we support. */ | 71 | + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, BC) != 0; |
465 | + uint32_t mask = (REG_MISTA_TXBERR | | ||
466 | + REG_MISTA_TDU | | ||
467 | + REG_MISTA_TXCP); | ||
468 | + if (emc->regs[REG_MISTA] & emc->regs[REG_MIEN] & mask) { | ||
469 | + emc->regs[REG_MISTA] |= REG_MISTA_TXINTR; | ||
470 | + } else { | ||
471 | + emc->regs[REG_MISTA] &= ~REG_MISTA_TXINTR; | ||
472 | + } | ||
473 | +} | 72 | +} |
474 | + | 73 | + |
475 | +/* MISTA.RXINTR is the union of the individual bits with their enables. */ | 74 | +static inline bool isar_feature_aa64_mops(const ARMISARegisters *id) |
476 | +static void emc_update_mista_rxintr(NPCM7xxEMCState *emc) | ||
477 | +{ | 75 | +{ |
478 | + /* Only look at the bits we support. */ | 76 | + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, MOPS); |
479 | + uint32_t mask = (REG_MISTA_RXBERR | | ||
480 | + REG_MISTA_RDU | | ||
481 | + REG_MISTA_RXGD); | ||
482 | + if (emc->regs[REG_MISTA] & emc->regs[REG_MIEN] & mask) { | ||
483 | + emc->regs[REG_MISTA] |= REG_MISTA_RXINTR; | ||
484 | + } else { | ||
485 | + emc->regs[REG_MISTA] &= ~REG_MISTA_RXINTR; | ||
486 | + } | ||
487 | +} | 77 | +} |
488 | + | 78 | + |
489 | +/* N.B. emc_update_mista_txintr must have already been called. */ | 79 | static inline bool isar_feature_aa64_fp_simd(const ARMISARegisters *id) |
490 | +static void emc_update_tx_irq(NPCM7xxEMCState *emc) | 80 | { |
491 | +{ | 81 | /* We always set the AdvSIMD and FP fields identically. */ |
492 | + int level = !!(emc->regs[REG_MISTA] & | 82 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pmuv3p5(const ARMISARegisters *id) |
493 | + emc->regs[REG_MIEN] & | 83 | FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; |
494 | + REG_MISTA_TXINTR); | 84 | } |
495 | + trace_npcm7xx_emc_update_tx_irq(level); | 85 | |
496 | + qemu_set_irq(emc->tx_irq, level); | 86 | -static inline bool isar_feature_aa64_rcpc_8_3(const ARMISARegisters *id) |
497 | +} | 87 | -{ |
498 | + | 88 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) != 0; |
499 | +/* N.B. emc_update_mista_rxintr must have already been called. */ | 89 | -} |
500 | +static void emc_update_rx_irq(NPCM7xxEMCState *emc) | 90 | - |
501 | +{ | 91 | -static inline bool isar_feature_aa64_rcpc_8_4(const ARMISARegisters *id) |
502 | + int level = !!(emc->regs[REG_MISTA] & | 92 | -{ |
503 | + emc->regs[REG_MIEN] & | 93 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) >= 2; |
504 | + REG_MISTA_RXINTR); | 94 | -} |
505 | + trace_npcm7xx_emc_update_rx_irq(level); | 95 | - |
506 | + qemu_set_irq(emc->rx_irq, level); | 96 | -static inline bool isar_feature_aa64_i8mm(const ARMISARegisters *id) |
507 | +} | 97 | -{ |
508 | + | 98 | - return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, I8MM) != 0; |
509 | +/* Update IRQ states due to changes in MIEN,MISTA. */ | 99 | -} |
510 | +static void emc_update_irq_from_reg_change(NPCM7xxEMCState *emc) | 100 | - |
511 | +{ | 101 | -static inline bool isar_feature_aa64_hbc(const ARMISARegisters *id) |
512 | + emc_update_mista_txintr(emc); | 102 | -{ |
513 | + emc_update_tx_irq(emc); | 103 | - return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, BC) != 0; |
514 | + | 104 | -} |
515 | + emc_update_mista_rxintr(emc); | 105 | - |
516 | + emc_update_rx_irq(emc); | 106 | static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) |
517 | +} | 107 | { |
518 | + | 108 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; |
519 | +static int emc_read_tx_desc(dma_addr_t addr, NPCM7xxEMCTxDesc *desc) | 109 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_doublelock(const ARMISARegisters *id) |
520 | +{ | 110 | return FIELD_SEX64(id->id_aa64dfr0, ID_AA64DFR0, DOUBLELOCK) >= 0; |
521 | + if (dma_memory_read(&address_space_memory, addr, desc, sizeof(*desc))) { | 111 | } |
522 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read descriptor @ 0x%" | 112 | |
523 | + HWADDR_PRIx "\n", __func__, addr); | 113 | -static inline bool isar_feature_aa64_mops(const ARMISARegisters *id) |
524 | + return -1; | 114 | -{ |
525 | + } | 115 | - return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, MOPS); |
526 | + desc->flags = le32_to_cpu(desc->flags); | 116 | -} |
527 | + desc->txbsa = le32_to_cpu(desc->txbsa); | 117 | - |
528 | + desc->status_and_length = le32_to_cpu(desc->status_and_length); | 118 | /* |
529 | + desc->ntxdsa = le32_to_cpu(desc->ntxdsa); | 119 | * Feature tests for "does this exist in either 32-bit or 64-bit?" |
530 | + return 0; | 120 | */ |
531 | +} | ||
532 | + | ||
533 | +static int emc_write_tx_desc(const NPCM7xxEMCTxDesc *desc, dma_addr_t addr) | ||
534 | +{ | ||
535 | + NPCM7xxEMCTxDesc le_desc; | ||
536 | + | ||
537 | + le_desc.flags = cpu_to_le32(desc->flags); | ||
538 | + le_desc.txbsa = cpu_to_le32(desc->txbsa); | ||
539 | + le_desc.status_and_length = cpu_to_le32(desc->status_and_length); | ||
540 | + le_desc.ntxdsa = cpu_to_le32(desc->ntxdsa); | ||
541 | + if (dma_memory_write(&address_space_memory, addr, &le_desc, | ||
542 | + sizeof(le_desc))) { | ||
543 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to write descriptor @ 0x%" | ||
544 | + HWADDR_PRIx "\n", __func__, addr); | ||
545 | + return -1; | ||
546 | + } | ||
547 | + return 0; | ||
548 | +} | ||
549 | + | ||
550 | +static int emc_read_rx_desc(dma_addr_t addr, NPCM7xxEMCRxDesc *desc) | ||
551 | +{ | ||
552 | + if (dma_memory_read(&address_space_memory, addr, desc, sizeof(*desc))) { | ||
553 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read descriptor @ 0x%" | ||
554 | + HWADDR_PRIx "\n", __func__, addr); | ||
555 | + return -1; | ||
556 | + } | ||
557 | + desc->status_and_length = le32_to_cpu(desc->status_and_length); | ||
558 | + desc->rxbsa = le32_to_cpu(desc->rxbsa); | ||
559 | + desc->reserved = le32_to_cpu(desc->reserved); | ||
560 | + desc->nrxdsa = le32_to_cpu(desc->nrxdsa); | ||
561 | + return 0; | ||
562 | +} | ||
563 | + | ||
564 | +static int emc_write_rx_desc(const NPCM7xxEMCRxDesc *desc, dma_addr_t addr) | ||
565 | +{ | ||
566 | + NPCM7xxEMCRxDesc le_desc; | ||
567 | + | ||
568 | + le_desc.status_and_length = cpu_to_le32(desc->status_and_length); | ||
569 | + le_desc.rxbsa = cpu_to_le32(desc->rxbsa); | ||
570 | + le_desc.reserved = cpu_to_le32(desc->reserved); | ||
571 | + le_desc.nrxdsa = cpu_to_le32(desc->nrxdsa); | ||
572 | + if (dma_memory_write(&address_space_memory, addr, &le_desc, | ||
573 | + sizeof(le_desc))) { | ||
574 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to write descriptor @ 0x%" | ||
575 | + HWADDR_PRIx "\n", __func__, addr); | ||
576 | + return -1; | ||
577 | + } | ||
578 | + return 0; | ||
579 | +} | ||
580 | + | ||
581 | +static void emc_set_mista(NPCM7xxEMCState *emc, uint32_t flags) | ||
582 | +{ | ||
583 | + trace_npcm7xx_emc_set_mista(flags); | ||
584 | + emc->regs[REG_MISTA] |= flags; | ||
585 | + if (extract32(flags, 16, 16)) { | ||
586 | + emc_update_mista_txintr(emc); | ||
587 | + } | ||
588 | + if (extract32(flags, 0, 16)) { | ||
589 | + emc_update_mista_rxintr(emc); | ||
590 | + } | ||
591 | +} | ||
592 | + | ||
593 | +static void emc_halt_tx(NPCM7xxEMCState *emc, uint32_t mista_flag) | ||
594 | +{ | ||
595 | + emc->tx_active = false; | ||
596 | + emc_set_mista(emc, mista_flag); | ||
597 | +} | ||
598 | + | ||
599 | +static void emc_halt_rx(NPCM7xxEMCState *emc, uint32_t mista_flag) | ||
600 | +{ | ||
601 | + emc->rx_active = false; | ||
602 | + emc_set_mista(emc, mista_flag); | ||
603 | +} | ||
604 | + | ||
605 | +static void emc_set_next_tx_descriptor(NPCM7xxEMCState *emc, | ||
606 | + const NPCM7xxEMCTxDesc *tx_desc, | ||
607 | + uint32_t desc_addr) | ||
608 | +{ | ||
609 | + /* Update the current descriptor, if only to reset the owner flag. */ | ||
610 | + if (emc_write_tx_desc(tx_desc, desc_addr)) { | ||
611 | + /* | ||
612 | + * We just read it so this shouldn't generally happen. | ||
613 | + * Error already reported. | ||
614 | + */ | ||
615 | + emc_set_mista(emc, REG_MISTA_TXBERR); | ||
616 | + } | ||
617 | + emc->regs[REG_CTXDSA] = TX_DESC_NTXDSA(tx_desc->ntxdsa); | ||
618 | +} | ||
619 | + | ||
620 | +static void emc_set_next_rx_descriptor(NPCM7xxEMCState *emc, | ||
621 | + const NPCM7xxEMCRxDesc *rx_desc, | ||
622 | + uint32_t desc_addr) | ||
623 | +{ | ||
624 | + /* Update the current descriptor, if only to reset the owner flag. */ | ||
625 | + if (emc_write_rx_desc(rx_desc, desc_addr)) { | ||
626 | + /* | ||
627 | + * We just read it so this shouldn't generally happen. | ||
628 | + * Error already reported. | ||
629 | + */ | ||
630 | + emc_set_mista(emc, REG_MISTA_RXBERR); | ||
631 | + } | ||
632 | + emc->regs[REG_CRXDSA] = RX_DESC_NRXDSA(rx_desc->nrxdsa); | ||
633 | +} | ||
634 | + | ||
635 | +static void emc_try_send_next_packet(NPCM7xxEMCState *emc) | ||
636 | +{ | ||
637 | + /* Working buffer for sending out packets. Most packets fit in this. */ | ||
638 | +#define TX_BUFFER_SIZE 2048 | ||
639 | + uint8_t tx_send_buffer[TX_BUFFER_SIZE]; | ||
640 | + uint32_t desc_addr = TX_DESC_NTXDSA(emc->regs[REG_CTXDSA]); | ||
641 | + NPCM7xxEMCTxDesc tx_desc; | ||
642 | + uint32_t next_buf_addr, length; | ||
643 | + uint8_t *buf; | ||
644 | + g_autofree uint8_t *malloced_buf = NULL; | ||
645 | + | ||
646 | + if (emc_read_tx_desc(desc_addr, &tx_desc)) { | ||
647 | + /* Error reading descriptor, already reported. */ | ||
648 | + emc_halt_tx(emc, REG_MISTA_TXBERR); | ||
649 | + emc_update_tx_irq(emc); | ||
650 | + return; | ||
651 | + } | ||
652 | + | ||
653 | + /* Nothing we can do if we don't own the descriptor. */ | ||
654 | + if (!(tx_desc.flags & TX_DESC_FLAG_OWNER_MASK)) { | ||
655 | + trace_npcm7xx_emc_cpu_owned_desc(desc_addr); | ||
656 | + emc_halt_tx(emc, REG_MISTA_TDU); | ||
657 | + emc_update_tx_irq(emc); | ||
658 | + return; | ||
659 | + } | ||
660 | + | ||
661 | + /* Give the descriptor back regardless of what happens. */ | ||
662 | + tx_desc.flags &= ~TX_DESC_FLAG_OWNER_MASK; | ||
663 | + tx_desc.status_and_length &= 0xffff; | ||
664 | + | ||
665 | + /* | ||
666 | + * Despite the h/w documentation saying the tx buffer is word aligned, | ||
667 | + * the linux driver does not word align the buffer. There is value in not | ||
668 | + * aligning the buffer: See the description of NET_IP_ALIGN in linux | ||
669 | + * kernel sources. | ||
670 | + */ | ||
671 | + next_buf_addr = tx_desc.txbsa; | ||
672 | + emc->regs[REG_CTXBSA] = next_buf_addr; | ||
673 | + length = TX_DESC_PKT_LEN(tx_desc.status_and_length); | ||
674 | + buf = &tx_send_buffer[0]; | ||
675 | + | ||
676 | + if (length > sizeof(tx_send_buffer)) { | ||
677 | + malloced_buf = g_malloc(length); | ||
678 | + buf = malloced_buf; | ||
679 | + } | ||
680 | + | ||
681 | + if (dma_memory_read(&address_space_memory, next_buf_addr, buf, length)) { | ||
682 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read packet @ 0x%x\n", | ||
683 | + __func__, next_buf_addr); | ||
684 | + emc_set_mista(emc, REG_MISTA_TXBERR); | ||
685 | + emc_set_next_tx_descriptor(emc, &tx_desc, desc_addr); | ||
686 | + emc_update_tx_irq(emc); | ||
687 | + trace_npcm7xx_emc_tx_done(emc->regs[REG_CTXDSA]); | ||
688 | + return; | ||
689 | + } | ||
690 | + | ||
691 | + if ((tx_desc.flags & TX_DESC_FLAG_PADEN) && (length < MIN_PACKET_LENGTH)) { | ||
692 | + memset(buf + length, 0, MIN_PACKET_LENGTH - length); | ||
693 | + length = MIN_PACKET_LENGTH; | ||
694 | + } | ||
695 | + | ||
696 | + /* N.B. emc_receive can get called here. */ | ||
697 | + qemu_send_packet(qemu_get_queue(emc->nic), buf, length); | ||
698 | + trace_npcm7xx_emc_sent_packet(length); | ||
699 | + | ||
700 | + tx_desc.status_and_length |= TX_DESC_STATUS_TXCP; | ||
701 | + if (tx_desc.flags & TX_DESC_FLAG_INTEN) { | ||
702 | + emc_set_mista(emc, REG_MISTA_TXCP); | ||
703 | + } | ||
704 | + if (emc->regs[REG_MISTA] & emc->regs[REG_MIEN] & REG_MISTA_TXINTR) { | ||
705 | + tx_desc.status_and_length |= TX_DESC_STATUS_TXINTR; | ||
706 | + } | ||
707 | + | ||
708 | + emc_set_next_tx_descriptor(emc, &tx_desc, desc_addr); | ||
709 | + emc_update_tx_irq(emc); | ||
710 | + trace_npcm7xx_emc_tx_done(emc->regs[REG_CTXDSA]); | ||
711 | +} | ||
712 | + | ||
713 | +static bool emc_can_receive(NetClientState *nc) | ||
714 | +{ | ||
715 | + NPCM7xxEMCState *emc = NPCM7XX_EMC(qemu_get_nic_opaque(nc)); | ||
716 | + | ||
717 | + bool can_receive = emc->rx_active; | ||
718 | + trace_npcm7xx_emc_can_receive(can_receive); | ||
719 | + return can_receive; | ||
720 | +} | ||
721 | + | ||
722 | +/* If result is false then *fail_reason contains the reason. */ | ||
723 | +static bool emc_receive_filter1(NPCM7xxEMCState *emc, const uint8_t *buf, | ||
724 | + size_t len, const char **fail_reason) | ||
725 | +{ | ||
726 | + eth_pkt_types_e pkt_type = get_eth_packet_type(PKT_GET_ETH_HDR(buf)); | ||
727 | + | ||
728 | + switch (pkt_type) { | ||
729 | + case ETH_PKT_BCAST: | ||
730 | + if (emc->regs[REG_CAMCMR] & REG_CAMCMR_CCAM) { | ||
731 | + return true; | ||
732 | + } else { | ||
733 | + *fail_reason = "Broadcast packet disabled"; | ||
734 | + return !!(emc->regs[REG_CAMCMR] & REG_CAMCMR_ABP); | ||
735 | + } | ||
736 | + case ETH_PKT_MCAST: | ||
737 | + if (emc->regs[REG_CAMCMR] & REG_CAMCMR_CCAM) { | ||
738 | + return true; | ||
739 | + } else { | ||
740 | + *fail_reason = "Multicast packet disabled"; | ||
741 | + return !!(emc->regs[REG_CAMCMR] & REG_CAMCMR_AMP); | ||
742 | + } | ||
743 | + case ETH_PKT_UCAST: { | ||
744 | + bool matches; | ||
745 | + if (emc->regs[REG_CAMCMR] & REG_CAMCMR_AUP) { | ||
746 | + return true; | ||
747 | + } | ||
748 | + matches = ((emc->regs[REG_CAMCMR] & REG_CAMCMR_ECMP) && | ||
749 | + /* We only support one CAM register, CAM0. */ | ||
750 | + (emc->regs[REG_CAMEN] & (1 << 0)) && | ||
751 | + memcmp(buf, emc->conf.macaddr.a, ETH_ALEN) == 0); | ||
752 | + if (emc->regs[REG_CAMCMR] & REG_CAMCMR_CCAM) { | ||
753 | + *fail_reason = "MACADDR matched, comparison complemented"; | ||
754 | + return !matches; | ||
755 | + } else { | ||
756 | + *fail_reason = "MACADDR didn't match"; | ||
757 | + return matches; | ||
758 | + } | ||
759 | + } | ||
760 | + default: | ||
761 | + g_assert_not_reached(); | ||
762 | + } | ||
763 | +} | ||
764 | + | ||
765 | +static bool emc_receive_filter(NPCM7xxEMCState *emc, const uint8_t *buf, | ||
766 | + size_t len) | ||
767 | +{ | ||
768 | + const char *fail_reason = NULL; | ||
769 | + bool ok = emc_receive_filter1(emc, buf, len, &fail_reason); | ||
770 | + if (!ok) { | ||
771 | + trace_npcm7xx_emc_packet_filtered_out(fail_reason); | ||
772 | + } | ||
773 | + return ok; | ||
774 | +} | ||
775 | + | ||
776 | +static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) | ||
777 | +{ | ||
778 | + NPCM7xxEMCState *emc = NPCM7XX_EMC(qemu_get_nic_opaque(nc)); | ||
779 | + const uint32_t len = len1; | ||
780 | + size_t max_frame_len; | ||
781 | + bool long_frame; | ||
782 | + uint32_t desc_addr; | ||
783 | + NPCM7xxEMCRxDesc rx_desc; | ||
784 | + uint32_t crc; | ||
785 | + uint8_t *crc_ptr; | ||
786 | + uint32_t buf_addr; | ||
787 | + | ||
788 | + trace_npcm7xx_emc_receiving_packet(len); | ||
789 | + | ||
790 | + if (!emc_can_receive(nc)) { | ||
791 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unexpected packet\n", __func__); | ||
792 | + return -1; | ||
793 | + } | ||
794 | + | ||
795 | + if (len < ETH_HLEN || | ||
796 | + /* Defensive programming: drop unsupportable large packets. */ | ||
797 | + len > 0xffff - CRC_LENGTH) { | ||
798 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Dropped frame of %u bytes\n", | ||
799 | + __func__, len); | ||
800 | + return len; | ||
801 | + } | ||
802 | + | ||
803 | + /* | ||
804 | + * DENI is set if EMC received the Length/Type field of the incoming | ||
805 | + * packet, so it will be set regardless of what happens next. | ||
806 | + */ | ||
807 | + emc_set_mista(emc, REG_MISTA_DENI); | ||
808 | + | ||
809 | + if (!emc_receive_filter(emc, buf, len)) { | ||
810 | + emc_update_rx_irq(emc); | ||
811 | + return len; | ||
812 | + } | ||
813 | + | ||
814 | + /* Huge frames (> DMARFC) are dropped. */ | ||
815 | + max_frame_len = REG_DMARFC_RXMS(emc->regs[REG_DMARFC]); | ||
816 | + if (len + CRC_LENGTH > max_frame_len) { | ||
817 | + trace_npcm7xx_emc_packet_dropped(len); | ||
818 | + emc_set_mista(emc, REG_MISTA_DFOI); | ||
819 | + emc_update_rx_irq(emc); | ||
820 | + return len; | ||
821 | + } | ||
822 | + | ||
823 | + /* | ||
824 | + * Long Frames (> MAX_ETH_FRAME_SIZE) are also dropped, unless MCMDR.ALP | ||
825 | + * is set. | ||
826 | + */ | ||
827 | + long_frame = false; | ||
828 | + if (len + CRC_LENGTH > MAX_ETH_FRAME_SIZE) { | ||
829 | + if (emc->regs[REG_MCMDR] & REG_MCMDR_ALP) { | ||
830 | + long_frame = true; | ||
831 | + } else { | ||
832 | + trace_npcm7xx_emc_packet_dropped(len); | ||
833 | + emc_set_mista(emc, REG_MISTA_PTLE); | ||
834 | + emc_update_rx_irq(emc); | ||
835 | + return len; | ||
836 | + } | ||
837 | + } | ||
838 | + | ||
839 | + desc_addr = RX_DESC_NRXDSA(emc->regs[REG_CRXDSA]); | ||
840 | + if (emc_read_rx_desc(desc_addr, &rx_desc)) { | ||
841 | + /* Error reading descriptor, already reported. */ | ||
842 | + emc_halt_rx(emc, REG_MISTA_RXBERR); | ||
843 | + emc_update_rx_irq(emc); | ||
844 | + return len; | ||
845 | + } | ||
846 | + | ||
847 | + /* Nothing we can do if we don't own the descriptor. */ | ||
848 | + if (!(rx_desc.status_and_length & RX_DESC_STATUS_OWNER_MASK)) { | ||
849 | + trace_npcm7xx_emc_cpu_owned_desc(desc_addr); | ||
850 | + emc_halt_rx(emc, REG_MISTA_RDU); | ||
851 | + emc_update_rx_irq(emc); | ||
852 | + return len; | ||
853 | + } | ||
854 | + | ||
855 | + crc = 0; | ||
856 | + crc_ptr = (uint8_t *) &crc; | ||
857 | + if (!(emc->regs[REG_MCMDR] & REG_MCMDR_SPCRC)) { | ||
858 | + crc = cpu_to_be32(crc32(~0, buf, len)); | ||
859 | + } | ||
860 | + | ||
861 | + /* Give the descriptor back regardless of what happens. */ | ||
862 | + rx_desc.status_and_length &= ~RX_DESC_STATUS_OWNER_MASK; | ||
863 | + | ||
864 | + buf_addr = rx_desc.rxbsa; | ||
865 | + emc->regs[REG_CRXBSA] = buf_addr; | ||
866 | + if (dma_memory_write(&address_space_memory, buf_addr, buf, len) || | ||
867 | + (!(emc->regs[REG_MCMDR] & REG_MCMDR_SPCRC) && | ||
868 | + dma_memory_write(&address_space_memory, buf_addr + len, crc_ptr, | ||
869 | + 4))) { | ||
870 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bus error writing packet\n", | ||
871 | + __func__); | ||
872 | + emc_set_mista(emc, REG_MISTA_RXBERR); | ||
873 | + emc_set_next_rx_descriptor(emc, &rx_desc, desc_addr); | ||
874 | + emc_update_rx_irq(emc); | ||
875 | + trace_npcm7xx_emc_rx_done(emc->regs[REG_CRXDSA]); | ||
876 | + return len; | ||
877 | + } | ||
878 | + | ||
879 | + trace_npcm7xx_emc_received_packet(len); | ||
880 | + | ||
881 | + /* Note: We've already verified len+4 <= 0xffff. */ | ||
882 | + rx_desc.status_and_length = len; | ||
883 | + if (!(emc->regs[REG_MCMDR] & REG_MCMDR_SPCRC)) { | ||
884 | + rx_desc.status_and_length += 4; | ||
885 | + } | ||
886 | + rx_desc.status_and_length |= RX_DESC_STATUS_RXGD; | ||
887 | + emc_set_mista(emc, REG_MISTA_RXGD); | ||
888 | + | ||
889 | + if (emc->regs[REG_MISTA] & emc->regs[REG_MIEN] & REG_MISTA_RXINTR) { | ||
890 | + rx_desc.status_and_length |= RX_DESC_STATUS_RXINTR; | ||
891 | + } | ||
892 | + if (long_frame) { | ||
893 | + rx_desc.status_and_length |= RX_DESC_STATUS_PTLE; | ||
894 | + } | ||
895 | + | ||
896 | + emc_set_next_rx_descriptor(emc, &rx_desc, desc_addr); | ||
897 | + emc_update_rx_irq(emc); | ||
898 | + trace_npcm7xx_emc_rx_done(emc->regs[REG_CRXDSA]); | ||
899 | + return len; | ||
900 | +} | ||
901 | + | ||
902 | +static void emc_try_receive_next_packet(NPCM7xxEMCState *emc) | ||
903 | +{ | ||
904 | + if (emc_can_receive(qemu_get_queue(emc->nic))) { | ||
905 | + qemu_flush_queued_packets(qemu_get_queue(emc->nic)); | ||
906 | + } | ||
907 | +} | ||
908 | + | ||
909 | +static uint64_t npcm7xx_emc_read(void *opaque, hwaddr offset, unsigned size) | ||
910 | +{ | ||
911 | + NPCM7xxEMCState *emc = opaque; | ||
912 | + uint32_t reg = offset / sizeof(uint32_t); | ||
913 | + uint32_t result; | ||
914 | + | ||
915 | + if (reg >= NPCM7XX_NUM_EMC_REGS) { | ||
916 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
917 | + "%s: Invalid offset 0x%04" HWADDR_PRIx "\n", | ||
918 | + __func__, offset); | ||
919 | + return 0; | ||
920 | + } | ||
921 | + | ||
922 | + switch (reg) { | ||
923 | + case REG_MIID: | ||
924 | + /* | ||
925 | + * We don't implement MII. For determinism, always return zero as | ||
926 | + * writes record the last value written for debugging purposes. | ||
927 | + */ | ||
928 | + qemu_log_mask(LOG_UNIMP, "%s: Read of MIID, returning 0\n", __func__); | ||
929 | + result = 0; | ||
930 | + break; | ||
931 | + case REG_TSDR: | ||
932 | + case REG_RSDR: | ||
933 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
934 | + "%s: Read of write-only reg, %s/%d\n", | ||
935 | + __func__, emc_reg_name(reg), reg); | ||
936 | + return 0; | ||
937 | + default: | ||
938 | + result = emc->regs[reg]; | ||
939 | + break; | ||
940 | + } | ||
941 | + | ||
942 | + trace_npcm7xx_emc_reg_read(emc->emc_num, result, emc_reg_name(reg), reg); | ||
943 | + return result; | ||
944 | +} | ||
945 | + | ||
946 | +static void npcm7xx_emc_write(void *opaque, hwaddr offset, | ||
947 | + uint64_t v, unsigned size) | ||
948 | +{ | ||
949 | + NPCM7xxEMCState *emc = opaque; | ||
950 | + uint32_t reg = offset / sizeof(uint32_t); | ||
951 | + uint32_t value = v; | ||
952 | + | ||
953 | + g_assert(size == sizeof(uint32_t)); | ||
954 | + | ||
955 | + if (reg >= NPCM7XX_NUM_EMC_REGS) { | ||
956 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
957 | + "%s: Invalid offset 0x%04" HWADDR_PRIx "\n", | ||
958 | + __func__, offset); | ||
959 | + return; | ||
960 | + } | ||
961 | + | ||
962 | + trace_npcm7xx_emc_reg_write(emc->emc_num, emc_reg_name(reg), reg, value); | ||
963 | + | ||
964 | + switch (reg) { | ||
965 | + case REG_CAMCMR: | ||
966 | + emc->regs[reg] = value; | ||
967 | + break; | ||
968 | + case REG_CAMEN: | ||
969 | + /* Only CAM0 is supported, don't pretend otherwise. */ | ||
970 | + if (value & ~1) { | ||
971 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
972 | + "%s: Only CAM0 is supported, cannot enable others" | ||
973 | + ": 0x%x\n", | ||
974 | + __func__, value); | ||
975 | + } | ||
976 | + emc->regs[reg] = value & 1; | ||
977 | + break; | ||
978 | + case REG_CAMM_BASE + 0: | ||
979 | + emc->regs[reg] = value; | ||
980 | + emc->conf.macaddr.a[0] = value >> 24; | ||
981 | + emc->conf.macaddr.a[1] = value >> 16; | ||
982 | + emc->conf.macaddr.a[2] = value >> 8; | ||
983 | + emc->conf.macaddr.a[3] = value >> 0; | ||
984 | + break; | ||
985 | + case REG_CAML_BASE + 0: | ||
986 | + emc->regs[reg] = value; | ||
987 | + emc->conf.macaddr.a[4] = value >> 24; | ||
988 | + emc->conf.macaddr.a[5] = value >> 16; | ||
989 | + break; | ||
990 | + case REG_MCMDR: { | ||
991 | + uint32_t prev; | ||
992 | + if (value & REG_MCMDR_SWR) { | ||
993 | + emc_soft_reset(emc); | ||
994 | + /* On h/w the reset happens over multiple cycles. For now KISS. */ | ||
995 | + break; | ||
996 | + } | ||
997 | + prev = emc->regs[reg]; | ||
998 | + emc->regs[reg] = value; | ||
999 | + /* Update tx state. */ | ||
1000 | + if (!(prev & REG_MCMDR_TXON) && | ||
1001 | + (value & REG_MCMDR_TXON)) { | ||
1002 | + emc->regs[REG_CTXDSA] = emc->regs[REG_TXDLSA]; | ||
1003 | + /* | ||
1004 | + * Linux kernel turns TX on with CPU still holding descriptor, | ||
1005 | + * which suggests we should wait for a write to TSDR before trying | ||
1006 | + * to send a packet: so we don't send one here. | ||
1007 | + */ | ||
1008 | + } else if ((prev & REG_MCMDR_TXON) && | ||
1009 | + !(value & REG_MCMDR_TXON)) { | ||
1010 | + emc->regs[REG_MGSTA] |= REG_MGSTA_TXHA; | ||
1011 | + } | ||
1012 | + if (!(value & REG_MCMDR_TXON)) { | ||
1013 | + emc_halt_tx(emc, 0); | ||
1014 | + } | ||
1015 | + /* Update rx state. */ | ||
1016 | + if (!(prev & REG_MCMDR_RXON) && | ||
1017 | + (value & REG_MCMDR_RXON)) { | ||
1018 | + emc->regs[REG_CRXDSA] = emc->regs[REG_RXDLSA]; | ||
1019 | + } else if ((prev & REG_MCMDR_RXON) && | ||
1020 | + !(value & REG_MCMDR_RXON)) { | ||
1021 | + emc->regs[REG_MGSTA] |= REG_MGSTA_RXHA; | ||
1022 | + } | ||
1023 | + if (!(value & REG_MCMDR_RXON)) { | ||
1024 | + emc_halt_rx(emc, 0); | ||
1025 | + } | ||
1026 | + break; | ||
1027 | + } | ||
1028 | + case REG_TXDLSA: | ||
1029 | + case REG_RXDLSA: | ||
1030 | + case REG_DMARFC: | ||
1031 | + case REG_MIID: | ||
1032 | + emc->regs[reg] = value; | ||
1033 | + break; | ||
1034 | + case REG_MIEN: | ||
1035 | + emc->regs[reg] = value; | ||
1036 | + emc_update_irq_from_reg_change(emc); | ||
1037 | + break; | ||
1038 | + case REG_MISTA: | ||
1039 | + /* Clear the bits that have 1 in "value". */ | ||
1040 | + emc->regs[reg] &= ~value; | ||
1041 | + emc_update_irq_from_reg_change(emc); | ||
1042 | + break; | ||
1043 | + case REG_MGSTA: | ||
1044 | + /* Clear the bits that have 1 in "value". */ | ||
1045 | + emc->regs[reg] &= ~value; | ||
1046 | + break; | ||
1047 | + case REG_TSDR: | ||
1048 | + if (emc->regs[REG_MCMDR] & REG_MCMDR_TXON) { | ||
1049 | + emc->tx_active = true; | ||
1050 | + /* Keep trying to send packets until we run out. */ | ||
1051 | + while (emc->tx_active) { | ||
1052 | + emc_try_send_next_packet(emc); | ||
1053 | + } | ||
1054 | + } | ||
1055 | + break; | ||
1056 | + case REG_RSDR: | ||
1057 | + if (emc->regs[REG_MCMDR] & REG_MCMDR_RXON) { | ||
1058 | + emc->rx_active = true; | ||
1059 | + emc_try_receive_next_packet(emc); | ||
1060 | + } | ||
1061 | + break; | ||
1062 | + case REG_MIIDA: | ||
1063 | + emc->regs[reg] = value & ~REG_MIIDA_BUSY; | ||
1064 | + break; | ||
1065 | + case REG_MRPC: | ||
1066 | + case REG_MRPCC: | ||
1067 | + case REG_MREPC: | ||
1068 | + case REG_CTXDSA: | ||
1069 | + case REG_CTXBSA: | ||
1070 | + case REG_CRXDSA: | ||
1071 | + case REG_CRXBSA: | ||
1072 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
1073 | + "%s: Write to read-only reg %s/%d\n", | ||
1074 | + __func__, emc_reg_name(reg), reg); | ||
1075 | + break; | ||
1076 | + default: | ||
1077 | + qemu_log_mask(LOG_UNIMP, "%s: Write to unimplemented reg %s/%d\n", | ||
1078 | + __func__, emc_reg_name(reg), reg); | ||
1079 | + break; | ||
1080 | + } | ||
1081 | +} | ||
1082 | + | ||
1083 | +static const struct MemoryRegionOps npcm7xx_emc_ops = { | ||
1084 | + .read = npcm7xx_emc_read, | ||
1085 | + .write = npcm7xx_emc_write, | ||
1086 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1087 | + .valid = { | ||
1088 | + .min_access_size = 4, | ||
1089 | + .max_access_size = 4, | ||
1090 | + .unaligned = false, | ||
1091 | + }, | ||
1092 | +}; | ||
1093 | + | ||
1094 | +static void emc_cleanup(NetClientState *nc) | ||
1095 | +{ | ||
1096 | + /* Nothing to do yet. */ | ||
1097 | +} | ||
1098 | + | ||
1099 | +static NetClientInfo net_npcm7xx_emc_info = { | ||
1100 | + .type = NET_CLIENT_DRIVER_NIC, | ||
1101 | + .size = sizeof(NICState), | ||
1102 | + .can_receive = emc_can_receive, | ||
1103 | + .receive = emc_receive, | ||
1104 | + .cleanup = emc_cleanup, | ||
1105 | + .link_status_changed = emc_set_link, | ||
1106 | +}; | ||
1107 | + | ||
1108 | +static void npcm7xx_emc_realize(DeviceState *dev, Error **errp) | ||
1109 | +{ | ||
1110 | + NPCM7xxEMCState *emc = NPCM7XX_EMC(dev); | ||
1111 | + SysBusDevice *sbd = SYS_BUS_DEVICE(emc); | ||
1112 | + | ||
1113 | + memory_region_init_io(&emc->iomem, OBJECT(emc), &npcm7xx_emc_ops, emc, | ||
1114 | + TYPE_NPCM7XX_EMC, 4 * KiB); | ||
1115 | + sysbus_init_mmio(sbd, &emc->iomem); | ||
1116 | + sysbus_init_irq(sbd, &emc->tx_irq); | ||
1117 | + sysbus_init_irq(sbd, &emc->rx_irq); | ||
1118 | + | ||
1119 | + qemu_macaddr_default_if_unset(&emc->conf.macaddr); | ||
1120 | + emc->nic = qemu_new_nic(&net_npcm7xx_emc_info, &emc->conf, | ||
1121 | + object_get_typename(OBJECT(dev)), dev->id, emc); | ||
1122 | + qemu_format_nic_info_str(qemu_get_queue(emc->nic), emc->conf.macaddr.a); | ||
1123 | +} | ||
1124 | + | ||
1125 | +static void npcm7xx_emc_unrealize(DeviceState *dev) | ||
1126 | +{ | ||
1127 | + NPCM7xxEMCState *emc = NPCM7XX_EMC(dev); | ||
1128 | + | ||
1129 | + qemu_del_nic(emc->nic); | ||
1130 | +} | ||
1131 | + | ||
1132 | +static const VMStateDescription vmstate_npcm7xx_emc = { | ||
1133 | + .name = TYPE_NPCM7XX_EMC, | ||
1134 | + .version_id = 0, | ||
1135 | + .minimum_version_id = 0, | ||
1136 | + .fields = (VMStateField[]) { | ||
1137 | + VMSTATE_UINT8(emc_num, NPCM7xxEMCState), | ||
1138 | + VMSTATE_UINT32_ARRAY(regs, NPCM7xxEMCState, NPCM7XX_NUM_EMC_REGS), | ||
1139 | + VMSTATE_BOOL(tx_active, NPCM7xxEMCState), | ||
1140 | + VMSTATE_BOOL(rx_active, NPCM7xxEMCState), | ||
1141 | + VMSTATE_END_OF_LIST(), | ||
1142 | + }, | ||
1143 | +}; | ||
1144 | + | ||
1145 | +static Property npcm7xx_emc_properties[] = { | ||
1146 | + DEFINE_NIC_PROPERTIES(NPCM7xxEMCState, conf), | ||
1147 | + DEFINE_PROP_END_OF_LIST(), | ||
1148 | +}; | ||
1149 | + | ||
1150 | +static void npcm7xx_emc_class_init(ObjectClass *klass, void *data) | ||
1151 | +{ | ||
1152 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
1153 | + | ||
1154 | + set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); | ||
1155 | + dc->desc = "NPCM7xx EMC Controller"; | ||
1156 | + dc->realize = npcm7xx_emc_realize; | ||
1157 | + dc->unrealize = npcm7xx_emc_unrealize; | ||
1158 | + dc->reset = npcm7xx_emc_reset; | ||
1159 | + dc->vmsd = &vmstate_npcm7xx_emc; | ||
1160 | + device_class_set_props(dc, npcm7xx_emc_properties); | ||
1161 | +} | ||
1162 | + | ||
1163 | +static const TypeInfo npcm7xx_emc_info = { | ||
1164 | + .name = TYPE_NPCM7XX_EMC, | ||
1165 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1166 | + .instance_size = sizeof(NPCM7xxEMCState), | ||
1167 | + .class_init = npcm7xx_emc_class_init, | ||
1168 | +}; | ||
1169 | + | ||
1170 | +static void npcm7xx_emc_register_type(void) | ||
1171 | +{ | ||
1172 | + type_register_static(&npcm7xx_emc_info); | ||
1173 | +} | ||
1174 | + | ||
1175 | +type_init(npcm7xx_emc_register_type) | ||
1176 | diff --git a/hw/net/meson.build b/hw/net/meson.build | ||
1177 | index XXXXXXX..XXXXXXX 100644 | ||
1178 | --- a/hw/net/meson.build | ||
1179 | +++ b/hw/net/meson.build | ||
1180 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_I82596_COMMON', if_true: files('i82596.c')) | ||
1181 | softmmu_ss.add(when: 'CONFIG_SUNHME', if_true: files('sunhme.c')) | ||
1182 | softmmu_ss.add(when: 'CONFIG_FTGMAC100', if_true: files('ftgmac100.c')) | ||
1183 | softmmu_ss.add(when: 'CONFIG_SUNGEM', if_true: files('sungem.c')) | ||
1184 | +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_emc.c')) | ||
1185 | |||
1186 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_eth.c')) | ||
1187 | softmmu_ss.add(when: 'CONFIG_COLDFIRE', if_true: files('mcf_fec.c')) | ||
1188 | diff --git a/hw/net/trace-events b/hw/net/trace-events | ||
1189 | index XXXXXXX..XXXXXXX 100644 | ||
1190 | --- a/hw/net/trace-events | ||
1191 | +++ b/hw/net/trace-events | ||
1192 | @@ -XXX,XX +XXX,XX @@ imx_fec_receive_last(int last) "rx frame flags 0x%04x" | ||
1193 | imx_enet_receive(size_t size) "len %zu" | ||
1194 | imx_enet_receive_len(uint64_t addr, int len) "rx_bd 0x%"PRIx64" length %d" | ||
1195 | imx_enet_receive_last(int last) "rx frame flags 0x%04x" | ||
1196 | + | ||
1197 | +# npcm7xx_emc.c | ||
1198 | +npcm7xx_emc_reset(int emc_num) "Resetting emc%d" | ||
1199 | +npcm7xx_emc_update_tx_irq(int level) "Setting tx irq to %d" | ||
1200 | +npcm7xx_emc_update_rx_irq(int level) "Setting rx irq to %d" | ||
1201 | +npcm7xx_emc_set_mista(uint32_t flags) "ORing 0x%x into MISTA" | ||
1202 | +npcm7xx_emc_cpu_owned_desc(uint32_t addr) "Can't process cpu-owned descriptor @0x%x" | ||
1203 | +npcm7xx_emc_sent_packet(uint32_t len) "Sent %u byte packet" | ||
1204 | +npcm7xx_emc_tx_done(uint32_t ctxdsa) "TX done, CTXDSA=0x%x" | ||
1205 | +npcm7xx_emc_can_receive(int can_receive) "Can receive: %d" | ||
1206 | +npcm7xx_emc_packet_filtered_out(const char* fail_reason) "Packet filtered out: %s" | ||
1207 | +npcm7xx_emc_packet_dropped(uint32_t len) "%u byte packet dropped" | ||
1208 | +npcm7xx_emc_receiving_packet(uint32_t len) "Receiving %u byte packet" | ||
1209 | +npcm7xx_emc_received_packet(uint32_t len) "Received %u byte packet" | ||
1210 | +npcm7xx_emc_rx_done(uint32_t crxdsa) "RX done, CRXDSA=0x%x" | ||
1211 | +npcm7xx_emc_reg_read(int emc_num, uint32_t result, const char *name, int regno) "emc%d: 0x%x = reg[%s/%d]" | ||
1212 | +npcm7xx_emc_reg_write(int emc_num, const char *name, int regno, uint32_t value) "emc%d: reg[%s/%d] = 0x%x" | ||
1213 | -- | 121 | -- |
1214 | 2.20.1 | 122 | 2.34.1 |
1215 | 123 | ||
1216 | 124 | diff view generated by jsdifflib |
1 | From: Rebecca Cran <rebecca@nuviainc.com> | 1 | Move all the ID_AA64PFR* feature test functions together. |
---|---|---|---|
2 | 2 | ||
3 | Add support for FEAT_SSBS. SSBS (Speculative Store Bypass Safe) is an | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | optional feature in ARMv8.0, and mandatory in ARMv8.5. | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20231024163510.2972081-6-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/cpu-features.h | 86 +++++++++++++++++++-------------------- | ||
9 | 1 file changed, 43 insertions(+), 43 deletions(-) | ||
5 | 10 | ||
6 | Signed-off-by: Rebecca Cran <rebecca@nuviainc.com> | 11 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210216224543.16142-2-rebecca@nuviainc.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 15 ++++++++++++++- | ||
12 | target/arm/internals.h | 6 ++++++ | ||
13 | target/arm/helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-a64.c | 12 ++++++++++++ | ||
15 | 4 files changed, 69 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 13 | --- a/target/arm/cpu-features.h |
20 | +++ b/target/arm/cpu.h | 14 | +++ b/target/arm/cpu-features.h |
21 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | 15 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_rme(const ARMISARegisters *id) |
22 | #define SCTLR_TE (1U << 30) /* AArch32 only */ | 16 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RME) != 0; |
23 | #define SCTLR_EnIB (1U << 30) /* v8.3, AArch64 only */ | ||
24 | #define SCTLR_EnIA (1U << 31) /* v8.3, AArch64 only */ | ||
25 | +#define SCTLR_DSSBS_32 (1U << 31) /* v8.5, AArch32 only */ | ||
26 | #define SCTLR_BT0 (1ULL << 35) /* v8.5-BTI */ | ||
27 | #define SCTLR_BT1 (1ULL << 36) /* v8.5-BTI */ | ||
28 | #define SCTLR_ITFSB (1ULL << 37) /* v8.5-MemTag */ | ||
29 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
30 | #define SCTLR_TCF (3ULL << 40) /* v8.5-MemTag */ | ||
31 | #define SCTLR_ATA0 (1ULL << 42) /* v8.5-MemTag */ | ||
32 | #define SCTLR_ATA (1ULL << 43) /* v8.5-MemTag */ | ||
33 | -#define SCTLR_DSSBS (1ULL << 44) /* v8.5 */ | ||
34 | +#define SCTLR_DSSBS_64 (1ULL << 44) /* v8.5, AArch64 only */ | ||
35 | |||
36 | #define CPTR_TCPAC (1U << 31) | ||
37 | #define CPTR_TTA (1U << 20) | ||
38 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
39 | #define CPSR_IL (1U << 20) | ||
40 | #define CPSR_DIT (1U << 21) | ||
41 | #define CPSR_PAN (1U << 22) | ||
42 | +#define CPSR_SSBS (1U << 23) | ||
43 | #define CPSR_J (1U << 24) | ||
44 | #define CPSR_IT_0_1 (3U << 25) | ||
45 | #define CPSR_Q (1U << 27) | ||
46 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
47 | #define PSTATE_A (1U << 8) | ||
48 | #define PSTATE_D (1U << 9) | ||
49 | #define PSTATE_BTYPE (3U << 10) | ||
50 | +#define PSTATE_SSBS (1U << 12) | ||
51 | #define PSTATE_IL (1U << 20) | ||
52 | #define PSTATE_SS (1U << 21) | ||
53 | #define PSTATE_PAN (1U << 22) | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_dit(const ARMISARegisters *id) | ||
55 | return FIELD_EX32(id->id_pfr0, ID_PFR0, DIT) != 0; | ||
56 | } | 17 | } |
57 | 18 | ||
58 | +static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id) | 19 | +static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) |
59 | +{ | 20 | +{ |
60 | + return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0; | 21 | + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; |
61 | +} | 22 | +} |
62 | + | 23 | + |
63 | /* | 24 | +static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) |
64 | * 64-bit feature tests via id registers. | 25 | +{ |
65 | */ | 26 | + int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); |
66 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | 27 | + if (key >= 2) { |
67 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; | 28 | + return true; /* FEAT_CSV2_2 */ |
68 | } | 29 | + } |
69 | 30 | + if (key == 1) { | |
31 | + key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
32 | + return key >= 2; /* FEAT_CSV2_1p2 */ | ||
33 | + } | ||
34 | + return false; | ||
35 | +} | ||
36 | + | ||
70 | +static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | 37 | +static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) |
71 | +{ | 38 | +{ |
72 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | 39 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; |
73 | +} | 40 | +} |
74 | + | 41 | + |
75 | /* | 42 | +static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) |
76 | * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
77 | */ | ||
78 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/internals.h | ||
81 | +++ b/target/arm/internals.h | ||
82 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, | ||
83 | if (isar_feature_aa32_dit(id)) { | ||
84 | valid |= CPSR_DIT; | ||
85 | } | ||
86 | + if (isar_feature_aa32_ssbs(id)) { | ||
87 | + valid |= CPSR_SSBS; | ||
88 | + } | ||
89 | |||
90 | return valid; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) | ||
93 | if (isar_feature_aa64_dit(id)) { | ||
94 | valid |= PSTATE_DIT; | ||
95 | } | ||
96 | + if (isar_feature_aa64_ssbs(id)) { | ||
97 | + valid |= PSTATE_SSBS; | ||
98 | + } | ||
99 | if (isar_feature_aa64_mte(id)) { | ||
100 | valid |= PSTATE_TCO; | ||
101 | } | ||
102 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/helper.c | ||
105 | +++ b/target/arm/helper.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dit_reginfo = { | ||
107 | .readfn = aa64_dit_read, .writefn = aa64_dit_write | ||
108 | }; | ||
109 | |||
110 | +static uint64_t aa64_ssbs_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
111 | +{ | 43 | +{ |
112 | + return env->pstate & PSTATE_SSBS; | 44 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; |
113 | +} | 45 | +} |
114 | + | 46 | + |
115 | +static void aa64_ssbs_write(CPUARMState *env, const ARMCPRegInfo *ri, | 47 | +static inline bool isar_feature_aa64_mte_insn_reg(const ARMISARegisters *id) |
116 | + uint64_t value) | ||
117 | +{ | 48 | +{ |
118 | + env->pstate = (env->pstate & ~PSTATE_SSBS) | (value & PSTATE_SSBS); | 49 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) != 0; |
119 | +} | 50 | +} |
120 | + | 51 | + |
121 | +static const ARMCPRegInfo ssbs_reginfo = { | 52 | +static inline bool isar_feature_aa64_mte(const ARMISARegisters *id) |
122 | + .name = "SSBS", .state = ARM_CP_STATE_AA64, | 53 | +{ |
123 | + .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 6, | 54 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) >= 2; |
124 | + .type = ARM_CP_NO_RAW, .access = PL0_RW, | 55 | +} |
125 | + .readfn = aa64_ssbs_read, .writefn = aa64_ssbs_write | ||
126 | +}; | ||
127 | + | 56 | + |
128 | static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, | 57 | +static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) |
129 | const ARMCPRegInfo *ri, | 58 | +{ |
130 | bool isread) | 59 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0; |
131 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 60 | +} |
132 | if (cpu_isar_feature(aa64_dit, cpu)) { | ||
133 | define_one_arm_cp_reg(cpu, &dit_reginfo); | ||
134 | } | ||
135 | + if (cpu_isar_feature(aa64_ssbs, cpu)) { | ||
136 | + define_one_arm_cp_reg(cpu, &ssbs_reginfo); | ||
137 | + } | ||
138 | |||
139 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | ||
140 | define_arm_cp_regs(cpu, vhe_reginfo); | ||
141 | @@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, | ||
142 | env->uncached_cpsr &= ~(CPSR_IL | CPSR_J); | ||
143 | env->daif |= mask; | ||
144 | |||
145 | + if (cpu_isar_feature(aa32_ssbs, env_archcpu(env))) { | ||
146 | + if (env->cp15.sctlr_el[new_el] & SCTLR_DSSBS_32) { | ||
147 | + env->uncached_cpsr |= CPSR_SSBS; | ||
148 | + } else { | ||
149 | + env->uncached_cpsr &= ~CPSR_SSBS; | ||
150 | + } | ||
151 | + } | ||
152 | + | 61 | + |
153 | if (new_mode == ARM_CPU_MODE_HYP) { | 62 | static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) |
154 | env->thumb = (env->cp15.sctlr_el[2] & SCTLR_TE) != 0; | 63 | { |
155 | env->elr_el[2] = env->regs[15]; | 64 | return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1; |
156 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | 65 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id) |
157 | new_mode |= PSTATE_TCO; | 66 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) != 0; |
158 | } | 67 | } |
159 | 68 | ||
160 | + if (cpu_isar_feature(aa64_ssbs, cpu)) { | 69 | -static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) |
161 | + if (env->cp15.sctlr_el[new_el] & SCTLR_DSSBS_64) { | 70 | -{ |
162 | + new_mode |= PSTATE_SSBS; | 71 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; |
163 | + } else { | 72 | -} |
164 | + new_mode &= ~PSTATE_SSBS; | 73 | - |
165 | + } | 74 | -static inline bool isar_feature_aa64_mte_insn_reg(const ARMISARegisters *id) |
166 | + } | 75 | -{ |
167 | + | 76 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) != 0; |
168 | pstate_write(env, PSTATE_DAIF | new_mode); | 77 | -} |
169 | env->aarch64 = 1; | 78 | - |
170 | aarch64_restore_sp(env, new_el); | 79 | -static inline bool isar_feature_aa64_mte(const ARMISARegisters *id) |
171 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 80 | -{ |
172 | index XXXXXXX..XXXXXXX 100644 | 81 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, MTE) >= 2; |
173 | --- a/target/arm/translate-a64.c | 82 | -} |
174 | +++ b/target/arm/translate-a64.c | 83 | - |
175 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | 84 | -static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) |
176 | tcg_temp_free_i32(t1); | 85 | -{ |
177 | break; | 86 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0; |
178 | 87 | -} | |
179 | + case 0x19: /* SSBS */ | 88 | - |
180 | + if (!dc_isar_feature(aa64_ssbs, s)) { | 89 | static inline bool isar_feature_aa64_pmuv3p1(const ARMISARegisters *id) |
181 | + goto do_unallocated; | 90 | { |
182 | + } | 91 | return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 4 && |
183 | + if (crm & 1) { | 92 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pmuv3p5(const ARMISARegisters *id) |
184 | + set_pstate_bits(PSTATE_SSBS); | 93 | FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) != 0xf; |
185 | + } else { | 94 | } |
186 | + clear_pstate_bits(PSTATE_SSBS); | 95 | |
187 | + } | 96 | -static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) |
188 | + /* Don't need to rebuild hflags since SSBS is a nop */ | 97 | -{ |
189 | + break; | 98 | - return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; |
190 | + | 99 | -} |
191 | case 0x1a: /* DIT */ | 100 | - |
192 | if (!dc_isar_feature(aa64_dit, s)) { | 101 | -static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) |
193 | goto do_unallocated; | 102 | -{ |
103 | - int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); | ||
104 | - if (key >= 2) { | ||
105 | - return true; /* FEAT_CSV2_2 */ | ||
106 | - } | ||
107 | - if (key == 1) { | ||
108 | - key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
109 | - return key >= 2; /* FEAT_CSV2_1p2 */ | ||
110 | - } | ||
111 | - return false; | ||
112 | -} | ||
113 | - | ||
114 | -static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) | ||
115 | -{ | ||
116 | - return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; | ||
117 | -} | ||
118 | - | ||
119 | static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) | ||
120 | { | ||
121 | return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; | ||
194 | -- | 122 | -- |
195 | 2.20.1 | 123 | 2.34.1 |
196 | 124 | ||
197 | 125 | diff view generated by jsdifflib |
1 | The AN524 has a PL031 RTC, which we have a model of; provide it | 1 | Move all the ID_AA64DFR* feature test functions together. |
---|---|---|---|
2 | rather than an unimplemented-device stub. | ||
3 | 2 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210215115138.20465-23-peter.maydell@linaro.org | 6 | Message-id: 20231024163510.2972081-7-peter.maydell@linaro.org |
8 | --- | 7 | --- |
9 | hw/arm/mps2-tz.c | 22 ++++++++++++++++++++-- | 8 | target/arm/cpu-features.h | 10 +++++----- |
10 | 1 file changed, 20 insertions(+), 2 deletions(-) | 9 | 1 file changed, 5 insertions(+), 5 deletions(-) |
11 | 10 | ||
12 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 11 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
13 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/mps2-tz.c | 13 | --- a/target/arm/cpu-features.h |
15 | +++ b/hw/arm/mps2-tz.c | 14 | +++ b/target/arm/cpu-features.h |
16 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id) |
17 | #include "hw/misc/tz-msc.h" | 16 | return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8; |
18 | #include "hw/arm/armsse.h" | ||
19 | #include "hw/dma/pl080.h" | ||
20 | +#include "hw/rtc/pl031.h" | ||
21 | #include "hw/ssi/pl022.h" | ||
22 | #include "hw/i2c/arm_sbcon_i2c.h" | ||
23 | #include "hw/net/lan9118.h" | ||
24 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | ||
25 | UnimplementedDeviceState gpio[4]; | ||
26 | UnimplementedDeviceState gfx; | ||
27 | UnimplementedDeviceState cldc; | ||
28 | - UnimplementedDeviceState rtc; | ||
29 | UnimplementedDeviceState usb; | ||
30 | + PL031State rtc; | ||
31 | PL080State dma[4]; | ||
32 | TZMSC msc[4]; | ||
33 | CMSDKAPBUART uart[6]; | ||
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, | ||
35 | return sysbus_mmio_get_region(s, 0); | ||
36 | } | 17 | } |
37 | 18 | ||
38 | +static MemoryRegion *make_rtc(MPS2TZMachineState *mms, void *opaque, | 19 | +static inline bool isar_feature_aa64_doublelock(const ARMISARegisters *id) |
39 | + const char *name, hwaddr size, | ||
40 | + const int *irqs) | ||
41 | +{ | 20 | +{ |
42 | + PL031State *pl031 = opaque; | 21 | + return FIELD_SEX64(id->id_aa64dfr0, ID_AA64DFR0, DOUBLELOCK) >= 0; |
43 | + SysBusDevice *s; | ||
44 | + | ||
45 | + object_initialize_child(OBJECT(mms), name, pl031, TYPE_PL031); | ||
46 | + s = SYS_BUS_DEVICE(pl031); | ||
47 | + sysbus_realize(s, &error_fatal); | ||
48 | + /* | ||
49 | + * The board docs don't give an IRQ number for the PL031, so | ||
50 | + * presumably it is not connected. | ||
51 | + */ | ||
52 | + return sysbus_mmio_get_region(s, 0); | ||
53 | +} | 22 | +} |
54 | + | 23 | + |
55 | static void create_non_mpc_ram(MPS2TZMachineState *mms) | 24 | static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) |
56 | { | 25 | { |
57 | /* | 26 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; |
58 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sme_fa64(const ARMISARegisters *id) |
59 | 28 | return FIELD_EX64(id->id_aa64smfr0, ID_AA64SMFR0, FA64); | |
60 | { /* port 9 reserved */ }, | 29 | } |
61 | { "clcd", make_unimp_dev, &mms->cldc, 0x4130a000, 0x1000 }, | 30 | |
62 | - { "rtc", make_unimp_dev, &mms->rtc, 0x4130b000, 0x1000 }, | 31 | -static inline bool isar_feature_aa64_doublelock(const ARMISARegisters *id) |
63 | + { "rtc", make_rtc, &mms->rtc, 0x4130b000, 0x1000 }, | 32 | -{ |
64 | }, | 33 | - return FIELD_SEX64(id->id_aa64dfr0, ID_AA64DFR0, DOUBLELOCK) >= 0; |
65 | }, { | 34 | -} |
66 | .name = "ahb_ppcexp0", | 35 | - |
36 | /* | ||
37 | * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
38 | */ | ||
67 | -- | 39 | -- |
68 | 2.20.1 | 40 | 2.34.1 |
69 | 41 | ||
70 | 42 | diff view generated by jsdifflib |
1 | Update old infocenter.arm.com URLs to the equivalent developer.arm.com | 1 | In commit 442c9d682c94fc2 when we converted the ERET, ERETAA, ERETAB |
---|---|---|---|
2 | ones (the old URLs should redirect, but we might as well avoid the | 2 | instructions to decodetree, the conversion accidentally lost the |
3 | redirection notice, and the new URLs are pleasantly shorter). | 3 | correct setting of the syndrome register when taking a trap because |
4 | of the FEAT_FGT HFGITR_EL1.ERET bit. Instead of reporting a correct | ||
5 | full syndrome value with the EC and IL bits, we only reported the low | ||
6 | two bits of the syndrome, because the call to syn_erettrap() got | ||
7 | dropped. | ||
4 | 8 | ||
5 | This commit covers the links to the MPS2 board TRM, the various | 9 | Fix the syndrome values for these traps by reinstating the |
6 | Application Notes, the IoTKit and SSE-200 documents. | 10 | syn_erettrap() calls. |
7 | 11 | ||
12 | Fixes: 442c9d682c94fc2 ("target/arm: Convert ERET, ERETAA, ERETAB to decodetree") | ||
13 | Cc: qemu-stable@nongnu.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20210215115138.20465-25-peter.maydell@linaro.org | 16 | Message-id: 20231024172438.2990945-1-peter.maydell@linaro.org |
11 | --- | 17 | --- |
12 | include/hw/arm/armsse.h | 4 ++-- | 18 | target/arm/tcg/translate-a64.c | 4 ++-- |
13 | include/hw/misc/armsse-cpuid.h | 2 +- | 19 | 1 file changed, 2 insertions(+), 2 deletions(-) |
14 | include/hw/misc/armsse-mhu.h | 2 +- | ||
15 | include/hw/misc/iotkit-secctl.h | 2 +- | ||
16 | include/hw/misc/iotkit-sysctl.h | 2 +- | ||
17 | include/hw/misc/iotkit-sysinfo.h | 2 +- | ||
18 | include/hw/misc/mps2-fpgaio.h | 2 +- | ||
19 | hw/arm/mps2-tz.c | 11 +++++------ | ||
20 | hw/misc/armsse-cpuid.c | 2 +- | ||
21 | hw/misc/armsse-mhu.c | 2 +- | ||
22 | hw/misc/iotkit-sysctl.c | 2 +- | ||
23 | hw/misc/iotkit-sysinfo.c | 2 +- | ||
24 | hw/misc/mps2-fpgaio.c | 2 +- | ||
25 | hw/misc/mps2-scc.c | 2 +- | ||
26 | 14 files changed, 19 insertions(+), 20 deletions(-) | ||
27 | 20 | ||
28 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | 21 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
29 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/hw/arm/armsse.h | 23 | --- a/target/arm/tcg/translate-a64.c |
31 | +++ b/include/hw/arm/armsse.h | 24 | +++ b/target/arm/tcg/translate-a64.c |
32 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ static bool trans_ERET(DisasContext *s, arg_ERET *a) |
33 | * hardware, which include the IoT Kit and the SSE-050, SSE-100 and | 26 | return false; |
34 | * SSE-200. Currently we model: | 27 | } |
35 | * - the Arm IoT Kit which is documented in | 28 | if (s->fgt_eret) { |
36 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | 29 | - gen_exception_insn_el(s, 0, EXCP_UDEF, 0, 2); |
37 | + * https://developer.arm.com/documentation/ecm0601256/latest | 30 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(0), 2); |
38 | * - the SSE-200 which is documented in | 31 | return true; |
39 | - * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | 32 | } |
40 | + * https://developer.arm.com/documentation/101104/latest/ | 33 | dst = tcg_temp_new_i64(); |
41 | * | 34 | @@ -XXX,XX +XXX,XX @@ static bool trans_ERETA(DisasContext *s, arg_reta *a) |
42 | * The IoTKit contains: | 35 | } |
43 | * a Cortex-M33 | 36 | /* The FGT trap takes precedence over an auth trap. */ |
44 | diff --git a/include/hw/misc/armsse-cpuid.h b/include/hw/misc/armsse-cpuid.h | 37 | if (s->fgt_eret) { |
45 | index XXXXXXX..XXXXXXX 100644 | 38 | - gen_exception_insn_el(s, 0, EXCP_UDEF, a->m ? 3 : 2, 2); |
46 | --- a/include/hw/misc/armsse-cpuid.h | 39 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(a->m ? 3 : 2), 2); |
47 | +++ b/include/hw/misc/armsse-cpuid.h | 40 | return true; |
48 | @@ -XXX,XX +XXX,XX @@ | 41 | } |
49 | /* | 42 | dst = tcg_temp_new_i64(); |
50 | * This is a model of the "CPU_IDENTITY" register block which is part of the | ||
51 | * Arm SSE-200 and documented in | ||
52 | - * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | ||
53 | + * https://developer.arm.com/documentation/101104/latest/ | ||
54 | * | ||
55 | * QEMU interface: | ||
56 | * + QOM property "CPUID": the value to use for the CPUID register | ||
57 | diff --git a/include/hw/misc/armsse-mhu.h b/include/hw/misc/armsse-mhu.h | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/include/hw/misc/armsse-mhu.h | ||
60 | +++ b/include/hw/misc/armsse-mhu.h | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | /* | ||
63 | * This is a model of the Message Handling Unit (MHU) which is part of the | ||
64 | * Arm SSE-200 and documented in | ||
65 | - * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | ||
66 | + * https://developer.arm.com/documentation/101104/latest/ | ||
67 | * | ||
68 | * QEMU interface: | ||
69 | * + sysbus MMIO region 0: the system information register bank | ||
70 | diff --git a/include/hw/misc/iotkit-secctl.h b/include/hw/misc/iotkit-secctl.h | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/include/hw/misc/iotkit-secctl.h | ||
73 | +++ b/include/hw/misc/iotkit-secctl.h | ||
74 | @@ -XXX,XX +XXX,XX @@ | ||
75 | |||
76 | /* This is a model of the security controller which is part of the | ||
77 | * Arm IoT Kit and documented in | ||
78 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
79 | + * https://developer.arm.com/documentation/ecm0601256/latest | ||
80 | * | ||
81 | * QEMU interface: | ||
82 | * + sysbus MMIO region 0 is the "secure privilege control block" registers | ||
83 | diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/include/hw/misc/iotkit-sysctl.h | ||
86 | +++ b/include/hw/misc/iotkit-sysctl.h | ||
87 | @@ -XXX,XX +XXX,XX @@ | ||
88 | /* | ||
89 | * This is a model of the "system control element" which is part of the | ||
90 | * Arm IoTKit and documented in | ||
91 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
92 | + * https://developer.arm.com/documentation/ecm0601256/latest | ||
93 | * Specifically, it implements the "system information block" and | ||
94 | * "system control register" blocks. | ||
95 | * | ||
96 | diff --git a/include/hw/misc/iotkit-sysinfo.h b/include/hw/misc/iotkit-sysinfo.h | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/include/hw/misc/iotkit-sysinfo.h | ||
99 | +++ b/include/hw/misc/iotkit-sysinfo.h | ||
100 | @@ -XXX,XX +XXX,XX @@ | ||
101 | /* | ||
102 | * This is a model of the "system information block" which is part of the | ||
103 | * Arm IoTKit and documented in | ||
104 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
105 | + * https://developer.arm.com/documentation/ecm0601256/latest | ||
106 | * QEMU interface: | ||
107 | * + QOM property "SYS_VERSION": value to use for SYS_VERSION register | ||
108 | * + QOM property "SYS_CONFIG": value to use for SYS_CONFIG register | ||
109 | diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/include/hw/misc/mps2-fpgaio.h | ||
112 | +++ b/include/hw/misc/mps2-fpgaio.h | ||
113 | @@ -XXX,XX +XXX,XX @@ | ||
114 | /* This is a model of the FPGAIO register block in the AN505 | ||
115 | * FPGA image for the MPS2 dev board; it is documented in the | ||
116 | * application note: | ||
117 | - * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | ||
118 | + * https://developer.arm.com/documentation/dai0505/latest/ | ||
119 | * | ||
120 | * QEMU interface: | ||
121 | * + sysbus MMIO region 0: the register bank | ||
122 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/arm/mps2-tz.c | ||
125 | +++ b/hw/arm/mps2-tz.c | ||
126 | @@ -XXX,XX +XXX,XX @@ | ||
127 | * https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps2 | ||
128 | * | ||
129 | * Board TRM: | ||
130 | - * http://infocenter.arm.com/help/topic/com.arm.doc.100112_0200_06_en/versatile_express_cortex_m_prototyping_systems_v2m_mps2_and_v2m_mps2plus_technical_reference_100112_0200_06_en.pdf | ||
131 | + * https://developer.arm.com/documentation/100112/latest/ | ||
132 | * Application Note AN505: | ||
133 | - * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | ||
134 | + * https://developer.arm.com/documentation/dai0505/latest/ | ||
135 | * Application Note AN521: | ||
136 | - * http://infocenter.arm.com/help/topic/com.arm.doc.dai0521c/index.html | ||
137 | + * https://developer.arm.com/documentation/dai0521/latest/ | ||
138 | * Application Note AN524: | ||
139 | * https://developer.arm.com/documentation/dai0524/latest/ | ||
140 | * | ||
141 | * The AN505 defers to the Cortex-M33 processor ARMv8M IoT Kit FVP User Guide | ||
142 | * (ARM ECM0601256) for the details of some of the device layout: | ||
143 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
144 | + * https://developer.arm.com/documentation/ecm0601256/latest | ||
145 | * Similarly, the AN521 and AN524 use the SSE-200, and the SSE-200 TRM defines | ||
146 | * most of the device layout: | ||
147 | - * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | ||
148 | - * | ||
149 | + * https://developer.arm.com/documentation/101104/latest/ | ||
150 | */ | ||
151 | |||
152 | #include "qemu/osdep.h" | ||
153 | diff --git a/hw/misc/armsse-cpuid.c b/hw/misc/armsse-cpuid.c | ||
154 | index XXXXXXX..XXXXXXX 100644 | ||
155 | --- a/hw/misc/armsse-cpuid.c | ||
156 | +++ b/hw/misc/armsse-cpuid.c | ||
157 | @@ -XXX,XX +XXX,XX @@ | ||
158 | /* | ||
159 | * This is a model of the "CPU_IDENTITY" register block which is part of the | ||
160 | * Arm SSE-200 and documented in | ||
161 | - * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | ||
162 | + * https://developer.arm.com/documentation/101104/latest/ | ||
163 | * | ||
164 | * It consists of one read-only CPUID register (set by QOM property), plus the | ||
165 | * usual ID registers. | ||
166 | diff --git a/hw/misc/armsse-mhu.c b/hw/misc/armsse-mhu.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/hw/misc/armsse-mhu.c | ||
169 | +++ b/hw/misc/armsse-mhu.c | ||
170 | @@ -XXX,XX +XXX,XX @@ | ||
171 | /* | ||
172 | * This is a model of the Message Handling Unit (MHU) which is part of the | ||
173 | * Arm SSE-200 and documented in | ||
174 | - * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf | ||
175 | + * https://developer.arm.com/documentation/101104/latest/ | ||
176 | */ | ||
177 | |||
178 | #include "qemu/osdep.h" | ||
179 | diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c | ||
180 | index XXXXXXX..XXXXXXX 100644 | ||
181 | --- a/hw/misc/iotkit-sysctl.c | ||
182 | +++ b/hw/misc/iotkit-sysctl.c | ||
183 | @@ -XXX,XX +XXX,XX @@ | ||
184 | /* | ||
185 | * This is a model of the "system control element" which is part of the | ||
186 | * Arm IoTKit and documented in | ||
187 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
188 | + * https://developer.arm.com/documentation/ecm0601256/latest | ||
189 | * Specifically, it implements the "system control register" blocks. | ||
190 | */ | ||
191 | |||
192 | diff --git a/hw/misc/iotkit-sysinfo.c b/hw/misc/iotkit-sysinfo.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/hw/misc/iotkit-sysinfo.c | ||
195 | +++ b/hw/misc/iotkit-sysinfo.c | ||
196 | @@ -XXX,XX +XXX,XX @@ | ||
197 | /* | ||
198 | * This is a model of the "system information block" which is part of the | ||
199 | * Arm IoTKit and documented in | ||
200 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
201 | + * https://developer.arm.com/documentation/ecm0601256/latest | ||
202 | * It consists of 2 read-only version/config registers, plus the | ||
203 | * usual ID registers. | ||
204 | */ | ||
205 | diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c | ||
206 | index XXXXXXX..XXXXXXX 100644 | ||
207 | --- a/hw/misc/mps2-fpgaio.c | ||
208 | +++ b/hw/misc/mps2-fpgaio.c | ||
209 | @@ -XXX,XX +XXX,XX @@ | ||
210 | /* This is a model of the "FPGA system control and I/O" block found | ||
211 | * in the AN505 FPGA image for the MPS2 devboard. | ||
212 | * It is documented in AN505: | ||
213 | - * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | ||
214 | + * https://developer.arm.com/documentation/dai0505/latest/ | ||
215 | */ | ||
216 | |||
217 | #include "qemu/osdep.h" | ||
218 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | ||
219 | index XXXXXXX..XXXXXXX 100644 | ||
220 | --- a/hw/misc/mps2-scc.c | ||
221 | +++ b/hw/misc/mps2-scc.c | ||
222 | @@ -XXX,XX +XXX,XX @@ | ||
223 | * found in the FPGA images of MPS2 development boards. | ||
224 | * | ||
225 | * Documentation of it can be found in the MPS2 TRM: | ||
226 | - * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100112_0100_03_en/index.html | ||
227 | + * https://developer.arm.com/documentation/100112/latest/ | ||
228 | * and also in the Application Notes documenting individual FPGA images. | ||
229 | */ | ||
230 | |||
231 | -- | 43 | -- |
232 | 2.20.1 | 44 | 2.34.1 |
233 | |||
234 | diff view generated by jsdifflib |
1 | Add brief documentation of the new mps3-an524 board. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | "hw/arm/boot.h" is only required on the source file. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-2-philmd@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210215115138.20465-24-peter.maydell@linaro.org | ||
7 | --- | 10 | --- |
8 | docs/system/arm/mps2.rst | 24 ++++++++++++++++++------ | 11 | include/hw/arm/allwinner-a10.h | 1 - |
9 | 1 file changed, 18 insertions(+), 6 deletions(-) | 12 | hw/arm/cubieboard.c | 1 + |
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
10 | 14 | ||
11 | diff --git a/docs/system/arm/mps2.rst b/docs/system/arm/mps2.rst | 15 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/docs/system/arm/mps2.rst | 17 | --- a/include/hw/arm/allwinner-a10.h |
14 | +++ b/docs/system/arm/mps2.rst | 18 | +++ b/include/hw/arm/allwinner-a10.h |
15 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
16 | -Arm MPS2 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, ``mps2-an505``, ``mps2-an511``, ``mps2-an521``) | 20 | #ifndef HW_ARM_ALLWINNER_A10_H |
17 | -================================================================================================================ | 21 | #define HW_ARM_ALLWINNER_A10_H |
18 | +Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``) | 22 | |
19 | +========================================================================================================================================= | 23 | -#include "hw/arm/boot.h" |
20 | 24 | #include "hw/timer/allwinner-a10-pit.h" | |
21 | These board models all use Arm M-profile CPUs. | 25 | #include "hw/intc/allwinner-a10-pic.h" |
22 | 26 | #include "hw/net/allwinner_emac.h" | |
23 | -The Arm MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger | 27 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c |
24 | -FPGA but is otherwise the same as the 2). Since the CPU itself | 28 | index XXXXXXX..XXXXXXX 100644 |
25 | -and most of the devices are in the FPGA, the details of the board | 29 | --- a/hw/arm/cubieboard.c |
26 | -as seen by the guest depend significantly on the FPGA image. | 30 | +++ b/hw/arm/cubieboard.c |
27 | +The Arm MPS2, MPS2+ and MPS3 dev boards are FPGA based (the 2+ has a | 31 | @@ -XXX,XX +XXX,XX @@ |
28 | +bigger FPGA but is otherwise the same as the 2; the 3 has a bigger | 32 | #include "hw/boards.h" |
29 | +FPGA again, can handle 4GB of RAM and has a USB controller and QSPI flash). | 33 | #include "hw/qdev-properties.h" |
30 | + | 34 | #include "hw/arm/allwinner-a10.h" |
31 | +Since the CPU itself and most of the devices are in the FPGA, the | 35 | +#include "hw/arm/boot.h" |
32 | +details of the board as seen by the guest depend significantly on the | 36 | #include "hw/i2c/i2c.h" |
33 | +FPGA image. | 37 | |
34 | 38 | static struct arm_boot_info cubieboard_binfo = { | |
35 | QEMU models the following FPGA images: | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ QEMU models the following FPGA images: | ||
38 | Cortex-M3 'DesignStart' as documented in Arm Application Note AN511 | ||
39 | ``mps2-an521`` | ||
40 | Dual Cortex-M33 as documented in Arm Application Note AN521 | ||
41 | +``mps3-an524`` | ||
42 | + Dual Cortex-M33 on an MPS3, as documented in Arm Application Note AN524 | ||
43 | |||
44 | Differences between QEMU and real hardware: | ||
45 | |||
46 | - AN385/AN386 remapping of low 16K of memory to either ZBT SSRAM1 or to | ||
47 | block RAM is unimplemented (QEMU always maps this to ZBT SSRAM1, as | ||
48 | if zbt_boot_ctrl is always zero) | ||
49 | +- AN524 remapping of low memory to either BRAM or to QSPI flash is | ||
50 | + unimplemented (QEMU always maps this to BRAM, ignoring the | ||
51 | + SCC CFG_REG0 memory-remap bit) | ||
52 | - QEMU provides a LAN9118 ethernet rather than LAN9220; the only guest | ||
53 | visible difference is that the LAN9118 doesn't support checksum | ||
54 | offloading | ||
55 | +- QEMU does not model the QSPI flash in MPS3 boards as real QSPI | ||
56 | + flash, but only as simple ROM, so attempting to rewrite the flash | ||
57 | + from the guest will fail | ||
58 | +- QEMU does not model the USB controller in MPS3 boards | ||
59 | -- | 39 | -- |
60 | 2.20.1 | 40 | 2.34.1 |
61 | 41 | ||
62 | 42 | diff view generated by jsdifflib |
1 | Set the FPGAIO num-leds and have-switches properties explicitly | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | per-board, rather than relying on the defaults. The AN505 and AN521 | ||
3 | both have the same settings as the default values, but the AN524 will | ||
4 | be different. | ||
5 | 2 | ||
3 | "hw/arm/boot.h" is only required on the source file. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-3-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210215115138.20465-8-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | hw/arm/mps2-tz.c | 9 +++++++++ | 11 | include/hw/arm/allwinner-h3.h | 1 - |
12 | 1 file changed, 9 insertions(+) | 12 | hw/arm/orangepi.c | 1 + |
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
13 | 14 | ||
14 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/mps2-tz.c | 17 | --- a/include/hw/arm/allwinner-h3.h |
17 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/include/hw/arm/allwinner-h3.h |
18 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | uint32_t sysclk_frq; /* Main SYSCLK frequency in Hz */ | 20 | #define HW_ARM_ALLWINNER_H3_H |
20 | uint32_t len_oscclk; | 21 | |
21 | const uint32_t *oscclk; | 22 | #include "qom/object.h" |
22 | + uint32_t fpgaio_num_leds; /* Number of LEDs in FPGAIO LED0 register */ | 23 | -#include "hw/arm/boot.h" |
23 | + bool fpgaio_has_switches; /* Does FPGAIO have SWITCH register? */ | 24 | #include "hw/timer/allwinner-a10-pit.h" |
24 | const char *armsse_type; | 25 | #include "hw/intc/arm_gic.h" |
25 | }; | 26 | #include "hw/misc/allwinner-h3-ccu.h" |
26 | 27 | diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c | |
27 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms, void *opaque, | 28 | index XXXXXXX..XXXXXXX 100644 |
28 | const char *name, hwaddr size) | 29 | --- a/hw/arm/orangepi.c |
29 | { | 30 | +++ b/hw/arm/orangepi.c |
30 | MPS2FPGAIO *fpgaio = opaque; | 31 | @@ -XXX,XX +XXX,XX @@ |
31 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 32 | #include "hw/boards.h" |
32 | 33 | #include "hw/qdev-properties.h" | |
33 | object_initialize_child(OBJECT(mms), "fpgaio", fpgaio, TYPE_MPS2_FPGAIO); | 34 | #include "hw/arm/allwinner-h3.h" |
34 | + qdev_prop_set_uint32(DEVICE(fpgaio), "num-leds", mmc->fpgaio_num_leds); | 35 | +#include "hw/arm/boot.h" |
35 | + qdev_prop_set_bit(DEVICE(fpgaio), "has-switches", mmc->fpgaio_has_switches); | 36 | |
36 | sysbus_realize(SYS_BUS_DEVICE(fpgaio), &error_fatal); | 37 | static struct arm_boot_info orangepi_binfo; |
37 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(fpgaio), 0); | ||
38 | } | ||
39 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | ||
40 | mmc->sysclk_frq = 20 * 1000 * 1000; /* 20MHz */ | ||
41 | mmc->oscclk = an505_oscclk; | ||
42 | mmc->len_oscclk = ARRAY_SIZE(an505_oscclk); | ||
43 | + mmc->fpgaio_num_leds = 2; | ||
44 | + mmc->fpgaio_has_switches = false; | ||
45 | mmc->armsse_type = TYPE_IOTKIT; | ||
46 | } | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
49 | mmc->sysclk_frq = 20 * 1000 * 1000; /* 20MHz */ | ||
50 | mmc->oscclk = an505_oscclk; /* AN521 is the same as AN505 here */ | ||
51 | mmc->len_oscclk = ARRAY_SIZE(an505_oscclk); | ||
52 | + mmc->fpgaio_num_leds = 2; | ||
53 | + mmc->fpgaio_has_switches = false; | ||
54 | mmc->armsse_type = TYPE_SSE200; | ||
55 | } | ||
56 | 38 | ||
57 | -- | 39 | -- |
58 | 2.20.1 | 40 | 2.34.1 |
59 | 41 | ||
60 | 42 | diff view generated by jsdifflib |
1 | MPS3 boards have an extra SWITCH register in the FPGAIO block which | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | reports the value of some switches. Implement this, governed by a | ||
3 | property the board code can use to specify whether whether it exists. | ||
4 | 2 | ||
3 | "hw/arm/boot.h" is only required on the source file. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-4-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210215115138.20465-7-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | include/hw/misc/mps2-fpgaio.h | 1 + | 11 | include/hw/arm/allwinner-r40.h | 1 - |
11 | hw/misc/mps2-fpgaio.c | 10 ++++++++++ | 12 | hw/arm/bananapi_m2u.c | 1 + |
12 | 2 files changed, 11 insertions(+) | 13 | 2 files changed, 1 insertion(+), 1 deletion(-) |
13 | 14 | ||
14 | diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h | 15 | diff --git a/include/hw/arm/allwinner-r40.h b/include/hw/arm/allwinner-r40.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/misc/mps2-fpgaio.h | 17 | --- a/include/hw/arm/allwinner-r40.h |
17 | +++ b/include/hw/misc/mps2-fpgaio.h | 18 | +++ b/include/hw/arm/allwinner-r40.h |
18 | @@ -XXX,XX +XXX,XX @@ struct MPS2FPGAIO { | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | MemoryRegion iomem; | 20 | #define HW_ARM_ALLWINNER_R40_H |
20 | LEDState *led[MPS2FPGAIO_MAX_LEDS]; | 21 | |
21 | uint32_t num_leds; | 22 | #include "qom/object.h" |
22 | + bool has_switches; | 23 | -#include "hw/arm/boot.h" |
23 | 24 | #include "hw/timer/allwinner-a10-pit.h" | |
24 | uint32_t led0; | 25 | #include "hw/intc/arm_gic.h" |
25 | uint32_t prescale; | 26 | #include "hw/sd/allwinner-sdhost.h" |
26 | diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c | 27 | diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c |
27 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/misc/mps2-fpgaio.c | 29 | --- a/hw/arm/bananapi_m2u.c |
29 | +++ b/hw/misc/mps2-fpgaio.c | 30 | +++ b/hw/arm/bananapi_m2u.c |
30 | @@ -XXX,XX +XXX,XX @@ REG32(CLK100HZ, 0x14) | 31 | @@ -XXX,XX +XXX,XX @@ |
31 | REG32(COUNTER, 0x18) | 32 | #include "hw/i2c/i2c.h" |
32 | REG32(PRESCALE, 0x1c) | 33 | #include "hw/qdev-properties.h" |
33 | REG32(PSCNTR, 0x20) | 34 | #include "hw/arm/allwinner-r40.h" |
34 | +REG32(SWITCH, 0x28) | 35 | +#include "hw/arm/boot.h" |
35 | REG32(MISC, 0x4c) | 36 | |
36 | 37 | static struct arm_boot_info bpim2u_binfo; | |
37 | static uint32_t counter_from_tickoff(int64_t now, int64_t tick_offset, int frq) | ||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size) | ||
39 | resync_counter(s); | ||
40 | r = s->pscntr; | ||
41 | break; | ||
42 | + case A_SWITCH: | ||
43 | + if (!s->has_switches) { | ||
44 | + goto bad_offset; | ||
45 | + } | ||
46 | + /* User-togglable board switches. We don't model that, so report 0. */ | ||
47 | + r = 0; | ||
48 | + break; | ||
49 | default: | ||
50 | + bad_offset: | ||
51 | qemu_log_mask(LOG_GUEST_ERROR, | ||
52 | "MPS2 FPGAIO read: bad offset %x\n", (int) offset); | ||
53 | r = 0; | ||
54 | @@ -XXX,XX +XXX,XX @@ static Property mps2_fpgaio_properties[] = { | ||
55 | DEFINE_PROP_UINT32("prescale-clk", MPS2FPGAIO, prescale_clk, 20000000), | ||
56 | /* Number of LEDs controlled by LED0 register */ | ||
57 | DEFINE_PROP_UINT32("num-leds", MPS2FPGAIO, num_leds, 2), | ||
58 | + DEFINE_PROP_BOOL("has-switches", MPS2FPGAIO, has_switches, false), | ||
59 | DEFINE_PROP_END_OF_LIST(), | ||
60 | }; | ||
61 | 38 | ||
62 | -- | 39 | -- |
63 | 2.20.1 | 40 | 2.34.1 |
64 | 41 | ||
65 | 42 | diff view generated by jsdifflib |
1 | The AN524 has a USB controller (an ISP1763); we don't have a model of | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | it but we should provide a stub "unimplemented-device" for it. This | ||
3 | is slightly complicated because the USB controller shares a PPC port | ||
4 | with the ethernet controller. | ||
5 | 2 | ||
6 | Implement a make_* function which provides creates a container | 3 | "hw/arm/boot.h" is only required on the source file. |
7 | MemoryRegion with both the ethernet controller and an | ||
8 | unimplemented-device stub for the USB controller. | ||
9 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-5-philmd@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210215115138.20465-22-peter.maydell@linaro.org | ||
14 | --- | 10 | --- |
15 | hw/arm/mps2-tz.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- | 11 | include/hw/arm/fsl-imx25.h | 1 - |
16 | 1 file changed, 47 insertions(+), 1 deletion(-) | 12 | hw/arm/imx25_pdk.c | 1 + |
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
17 | 14 | ||
18 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/mps2-tz.c | 17 | --- a/include/hw/arm/fsl-imx25.h |
21 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/include/hw/arm/fsl-imx25.h |
22 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | 19 | @@ -XXX,XX +XXX,XX @@ |
23 | 20 | #ifndef FSL_IMX25_H | |
24 | ARMSSE iotkit; | 21 | #define FSL_IMX25_H |
25 | MemoryRegion ram[MPS2TZ_RAM_MAX]; | 22 | |
26 | + MemoryRegion eth_usb_container; | 23 | -#include "hw/arm/boot.h" |
27 | + | 24 | #include "hw/intc/imx_avic.h" |
28 | MPS2SCC scc; | 25 | #include "hw/misc/imx25_ccm.h" |
29 | MPS2FPGAIO fpgaio; | 26 | #include "hw/char/imx_serial.h" |
30 | TZPPC ppc[5]; | 27 | diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c |
31 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | 28 | index XXXXXXX..XXXXXXX 100644 |
32 | UnimplementedDeviceState gfx; | 29 | --- a/hw/arm/imx25_pdk.c |
33 | UnimplementedDeviceState cldc; | 30 | +++ b/hw/arm/imx25_pdk.c |
34 | UnimplementedDeviceState rtc; | 31 | @@ -XXX,XX +XXX,XX @@ |
35 | + UnimplementedDeviceState usb; | 32 | #include "qapi/error.h" |
36 | PL080State dma[4]; | 33 | #include "hw/qdev-properties.h" |
37 | TZMSC msc[4]; | 34 | #include "hw/arm/fsl-imx25.h" |
38 | CMSDKAPBUART uart[6]; | 35 | +#include "hw/arm/boot.h" |
39 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | 36 | #include "hw/boards.h" |
40 | return sysbus_mmio_get_region(s, 0); | 37 | #include "qemu/error-report.h" |
41 | } | 38 | #include "sysemu/qtest.h" |
42 | |||
43 | +static MemoryRegion *make_eth_usb(MPS2TZMachineState *mms, void *opaque, | ||
44 | + const char *name, hwaddr size, | ||
45 | + const int *irqs) | ||
46 | +{ | ||
47 | + /* | ||
48 | + * The AN524 makes the ethernet and USB share a PPC port. | ||
49 | + * irqs[] is the ethernet IRQ. | ||
50 | + */ | ||
51 | + SysBusDevice *s; | ||
52 | + NICInfo *nd = &nd_table[0]; | ||
53 | + | ||
54 | + memory_region_init(&mms->eth_usb_container, OBJECT(mms), | ||
55 | + "mps2-tz-eth-usb-container", 0x200000); | ||
56 | + | ||
57 | + /* | ||
58 | + * In hardware this is a LAN9220; the LAN9118 is software compatible | ||
59 | + * except that it doesn't support the checksum-offload feature. | ||
60 | + */ | ||
61 | + qemu_check_nic_model(nd, "lan9118"); | ||
62 | + mms->lan9118 = qdev_new(TYPE_LAN9118); | ||
63 | + qdev_set_nic_properties(mms->lan9118, nd); | ||
64 | + | ||
65 | + s = SYS_BUS_DEVICE(mms->lan9118); | ||
66 | + sysbus_realize_and_unref(s, &error_fatal); | ||
67 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqs[0])); | ||
68 | + | ||
69 | + memory_region_add_subregion(&mms->eth_usb_container, | ||
70 | + 0, sysbus_mmio_get_region(s, 0)); | ||
71 | + | ||
72 | + /* The USB OTG controller is an ISP1763; we don't have a model of it. */ | ||
73 | + object_initialize_child(OBJECT(mms), "usb-otg", | ||
74 | + &mms->usb, TYPE_UNIMPLEMENTED_DEVICE); | ||
75 | + qdev_prop_set_string(DEVICE(&mms->usb), "name", "usb-otg"); | ||
76 | + qdev_prop_set_uint64(DEVICE(&mms->usb), "size", 0x100000); | ||
77 | + s = SYS_BUS_DEVICE(&mms->usb); | ||
78 | + sysbus_realize(s, &error_fatal); | ||
79 | + | ||
80 | + memory_region_add_subregion(&mms->eth_usb_container, | ||
81 | + 0x100000, sysbus_mmio_get_region(s, 0)); | ||
82 | + | ||
83 | + return &mms->eth_usb_container; | ||
84 | +} | ||
85 | + | ||
86 | static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | ||
87 | const char *name, hwaddr size, | ||
88 | const int *irqs) | ||
89 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
90 | { "gpio1", make_unimp_dev, &mms->gpio[1], 0x41101000, 0x1000 }, | ||
91 | { "gpio2", make_unimp_dev, &mms->gpio[2], 0x41102000, 0x1000 }, | ||
92 | { "gpio3", make_unimp_dev, &mms->gpio[3], 0x41103000, 0x1000 }, | ||
93 | - { "eth", make_eth_dev, NULL, 0x41400000, 0x100000, { 48 } }, | ||
94 | + { "eth-usb", make_eth_usb, NULL, 0x41400000, 0x200000, { 48 } }, | ||
95 | }, | ||
96 | }, | ||
97 | }; | ||
98 | -- | 39 | -- |
99 | 2.20.1 | 40 | 2.34.1 |
100 | 41 | ||
101 | 42 | diff view generated by jsdifflib |
1 | The AN505 and AN521 have the same device layout, but the AN524 is | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | somewhat different. Allow for more than one PPCInfo array, which can | ||
3 | be selected based on the board type. | ||
4 | 2 | ||
3 | "hw/arm/boot.h" is only required on the source file. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-6-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210215115138.20465-16-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | hw/arm/mps2-tz.c | 16 ++++++++++++++-- | 11 | include/hw/arm/fsl-imx31.h | 1 - |
10 | 1 file changed, 14 insertions(+), 2 deletions(-) | 12 | hw/arm/kzm.c | 1 + |
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
11 | 14 | ||
12 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/include/hw/arm/fsl-imx31.h b/include/hw/arm/fsl-imx31.h |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/mps2-tz.c | 17 | --- a/include/hw/arm/fsl-imx31.h |
15 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/include/hw/arm/fsl-imx31.h |
16 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 19 | @@ -XXX,XX +XXX,XX @@ |
17 | MemoryRegion *system_memory = get_system_memory(); | 20 | #ifndef FSL_IMX31_H |
18 | DeviceState *iotkitdev; | 21 | #define FSL_IMX31_H |
19 | DeviceState *dev_splitter; | 22 | |
20 | + const PPCInfo *ppcs; | 23 | -#include "hw/arm/boot.h" |
21 | + int num_ppcs; | 24 | #include "hw/intc/imx_avic.h" |
22 | int i; | 25 | #include "hw/misc/imx31_ccm.h" |
23 | 26 | #include "hw/char/imx_serial.h" | |
24 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | 27 | diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c |
25 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 28 | index XXXXXXX..XXXXXXX 100644 |
26 | * + wire up the PPC's control lines to the IoTKit object | 29 | --- a/hw/arm/kzm.c |
27 | */ | 30 | +++ b/hw/arm/kzm.c |
28 | 31 | @@ -XXX,XX +XXX,XX @@ | |
29 | - const PPCInfo ppcs[] = { { | 32 | #include "qemu/osdep.h" |
30 | + const PPCInfo an505_ppcs[] = { { | 33 | #include "qapi/error.h" |
31 | .name = "apb_ppcexp0", | 34 | #include "hw/arm/fsl-imx31.h" |
32 | .ports = { | 35 | +#include "hw/arm/boot.h" |
33 | { "ssram-0", make_mpc, &mms->ssram_mpc[0], 0x58007000, 0x1000 }, | 36 | #include "hw/boards.h" |
34 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 37 | #include "qemu/error-report.h" |
35 | }, | 38 | #include "exec/address-spaces.h" |
36 | }; | ||
37 | |||
38 | - for (i = 0; i < ARRAY_SIZE(ppcs); i++) { | ||
39 | + switch (mmc->fpga_type) { | ||
40 | + case FPGA_AN505: | ||
41 | + case FPGA_AN521: | ||
42 | + ppcs = an505_ppcs; | ||
43 | + num_ppcs = ARRAY_SIZE(an505_ppcs); | ||
44 | + break; | ||
45 | + default: | ||
46 | + g_assert_not_reached(); | ||
47 | + } | ||
48 | + | ||
49 | + for (i = 0; i < num_ppcs; i++) { | ||
50 | const PPCInfo *ppcinfo = &ppcs[i]; | ||
51 | TZPPC *ppc = &mms->ppc[i]; | ||
52 | DeviceState *ppcdev; | ||
53 | -- | 39 | -- |
54 | 2.20.1 | 40 | 2.34.1 |
55 | 41 | ||
56 | 42 | diff view generated by jsdifflib |
1 | We create an OR gate to wire together the overflow IRQs for all the | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | UARTs on the board; this has to have twice the number of inputs as | ||
3 | there are UARTs, since each UART feeds it a TX overflow and an RX | ||
4 | overflow interrupt line. Replace the hardcoded '10' with a | ||
5 | calculation based on the size of the uart[] array in the | ||
6 | MPS2TZMachineState. (We rely on OR gate inputs that are never wired | ||
7 | up or asserted being treated as always-zero.) | ||
8 | 2 | ||
3 | "hw/arm/boot.h" is only required on the source file. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-7-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20210215115138.20465-15-peter.maydell@linaro.org | ||
12 | --- | 10 | --- |
13 | hw/arm/mps2-tz.c | 11 ++++++++--- | 11 | include/hw/arm/fsl-imx6.h | 1 - |
14 | 1 file changed, 8 insertions(+), 3 deletions(-) | 12 | hw/arm/sabrelite.c | 1 + |
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
15 | 14 | ||
16 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/mps2-tz.c | 17 | --- a/include/hw/arm/fsl-imx6.h |
19 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/include/hw/arm/fsl-imx6.h |
20 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 19 | @@ -XXX,XX +XXX,XX @@ |
21 | */ | 20 | #ifndef FSL_IMX6_H |
22 | memory_region_add_subregion(system_memory, 0x80000000, machine->ram); | 21 | #define FSL_IMX6_H |
23 | 22 | ||
24 | - /* The overflow IRQs for all UARTs are ORed together. | 23 | -#include "hw/arm/boot.h" |
25 | + /* | 24 | #include "hw/cpu/a9mpcore.h" |
26 | + * The overflow IRQs for all UARTs are ORed together. | 25 | #include "hw/misc/imx6_ccm.h" |
27 | * Tx, Rx and "combined" IRQs are sent to the NVIC separately. | 26 | #include "hw/misc/imx6_src.h" |
28 | - * Create the OR gate for this. | 27 | diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c |
29 | + * Create the OR gate for this: it has one input for the TX overflow | 28 | index XXXXXXX..XXXXXXX 100644 |
30 | + * and one for the RX overflow for each UART we might have. | 29 | --- a/hw/arm/sabrelite.c |
31 | + * (If the board has fewer than the maximum possible number of UARTs | 30 | +++ b/hw/arm/sabrelite.c |
32 | + * those inputs are never wired up and are treated as always-zero.) | 31 | @@ -XXX,XX +XXX,XX @@ |
33 | */ | 32 | #include "qemu/osdep.h" |
34 | object_initialize_child(OBJECT(mms), "uart-irq-orgate", | 33 | #include "qapi/error.h" |
35 | &mms->uart_irq_orgate, TYPE_OR_IRQ); | 34 | #include "hw/arm/fsl-imx6.h" |
36 | - object_property_set_int(OBJECT(&mms->uart_irq_orgate), "num-lines", 10, | 35 | +#include "hw/arm/boot.h" |
37 | + object_property_set_int(OBJECT(&mms->uart_irq_orgate), "num-lines", | 36 | #include "hw/boards.h" |
38 | + 2 * ARRAY_SIZE(mms->uart), | 37 | #include "hw/qdev-properties.h" |
39 | &error_fatal); | 38 | #include "qemu/error-report.h" |
40 | qdev_realize(DEVICE(&mms->uart_irq_orgate), NULL, &error_fatal); | ||
41 | qdev_connect_gpio_out(DEVICE(&mms->uart_irq_orgate), 0, | ||
42 | -- | 39 | -- |
43 | 2.20.1 | 40 | 2.34.1 |
44 | 41 | ||
45 | 42 | diff view generated by jsdifflib |
1 | On the MPS2 boards, the first 32 interrupt lines are entirely | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | internal to the SSE; interrupt lines for devices outside the SSE | ||
3 | start at 32. In the application notes that document each FPGA image, | ||
4 | the interrupt wiring is documented from the point of view of the CPU, | ||
5 | so '0' is the first of the SSE's interrupts and the devices in the | ||
6 | FPGA image itself are '32' and up: so the UART 0 Receive interrupt is | ||
7 | 32, the SPI #0 interrupt is 51, and so on. | ||
8 | 2 | ||
9 | Within our implementation, because the external interrupts must be | 3 | "hw/arm/boot.h" is only required on the source file. |
10 | connected to the EXP_IRQ[0...n] lines of the SSE object, we made the | ||
11 | get_sse_irq_in() function take an irqno whose values start at 0 for | ||
12 | the first FPGA device interrupt. In this numbering scheme the UART 0 | ||
13 | Receive interrupt is 0, the SPI #0 interrupt is 19, and so on. | ||
14 | 4 | ||
15 | The result of these two different numbering schemes has been that | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
16 | half of the devices were wired up to the wrong IRQs: the UART IRQs | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | are wired up correctly, but the DMA and SPI devices were passing | 7 | Reviewed-by: Luc Michel <luc.michel@amd.com> |
18 | start-at-32 values to get_sse_irq_in() and so being mis-connected. | 8 | Message-id: 20231025065316.56817-8-philmd@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/fsl-imx6ul.h | 1 - | ||
12 | hw/arm/mcimx6ul-evk.c | 1 + | ||
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
19 | 14 | ||
20 | Fix the bug by making get_sse_irq_in() take values specified with the | 15 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
21 | same scheme that the hardware manuals use, to avoid confusion. | ||
22 | |||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
25 | Message-id: 20210215115138.20465-12-peter.maydell@linaro.org | ||
26 | --- | ||
27 | hw/arm/mps2-tz.c | 24 +++++++++++++++++------- | ||
28 | 1 file changed, 17 insertions(+), 7 deletions(-) | ||
29 | |||
30 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/arm/mps2-tz.c | 17 | --- a/include/hw/arm/fsl-imx6ul.h |
33 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/include/hw/arm/fsl-imx6ul.h |
34 | @@ -XXX,XX +XXX,XX @@ static void make_ram_alias(MemoryRegion *mr, const char *name, | 19 | @@ -XXX,XX +XXX,XX @@ |
35 | 20 | #ifndef FSL_IMX6UL_H | |
36 | static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) | 21 | #define FSL_IMX6UL_H |
37 | { | 22 | |
38 | - /* Return a qemu_irq which will signal IRQ n to all CPUs in the SSE. */ | 23 | -#include "hw/arm/boot.h" |
39 | + /* | 24 | #include "hw/cpu/a15mpcore.h" |
40 | + * Return a qemu_irq which will signal IRQ n to all CPUs in the | 25 | #include "hw/misc/imx6ul_ccm.h" |
41 | + * SSE. The irqno should be as the CPU sees it, so the first | 26 | #include "hw/misc/imx6_src.h" |
42 | + * external-to-the-SSE interrupt is 32. | 27 | diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c |
43 | + */ | 28 | index XXXXXXX..XXXXXXX 100644 |
44 | MachineClass *mc = MACHINE_GET_CLASS(mms); | 29 | --- a/hw/arm/mcimx6ul-evk.c |
45 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 30 | +++ b/hw/arm/mcimx6ul-evk.c |
46 | 31 | @@ -XXX,XX +XXX,XX @@ | |
47 | - assert(irqno < mmc->numirq); | 32 | #include "qemu/osdep.h" |
48 | + assert(irqno >= 32 && irqno < (mmc->numirq + 32)); | 33 | #include "qapi/error.h" |
49 | + | 34 | #include "hw/arm/fsl-imx6ul.h" |
50 | + /* | 35 | +#include "hw/arm/boot.h" |
51 | + * Convert from "CPU irq number" (as listed in the FPGA image | 36 | #include "hw/boards.h" |
52 | + * documentation) to the SSE external-interrupt number. | 37 | #include "hw/qdev-properties.h" |
53 | + */ | 38 | #include "qemu/error-report.h" |
54 | + irqno -= 32; | ||
55 | |||
56 | if (mc->max_cpus > 1) { | ||
57 | return qdev_get_gpio_in(DEVICE(&mms->cpu_irq_splitter[irqno]), 0); | ||
58 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
59 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
60 | CMSDKAPBUART *uart = opaque; | ||
61 | int i = uart - &mms->uart[0]; | ||
62 | - int rxirqno = i * 2; | ||
63 | - int txirqno = i * 2 + 1; | ||
64 | - int combirqno = i + 10; | ||
65 | + int rxirqno = i * 2 + 32; | ||
66 | + int txirqno = i * 2 + 33; | ||
67 | + int combirqno = i + 42; | ||
68 | SysBusDevice *s; | ||
69 | DeviceState *orgate_dev = DEVICE(&mms->uart_irq_orgate); | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | ||
72 | |||
73 | s = SYS_BUS_DEVICE(mms->lan9118); | ||
74 | sysbus_realize_and_unref(s, &error_fatal); | ||
75 | - sysbus_connect_irq(s, 0, get_sse_irq_in(mms, 16)); | ||
76 | + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, 48)); | ||
77 | return sysbus_mmio_get_region(s, 0); | ||
78 | } | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
81 | &error_fatal); | ||
82 | qdev_realize(DEVICE(&mms->uart_irq_orgate), NULL, &error_fatal); | ||
83 | qdev_connect_gpio_out(DEVICE(&mms->uart_irq_orgate), 0, | ||
84 | - get_sse_irq_in(mms, 15)); | ||
85 | + get_sse_irq_in(mms, 47)); | ||
86 | |||
87 | /* Most of the devices in the FPGA are behind Peripheral Protection | ||
88 | * Controllers. The required order for initializing things is: | ||
89 | -- | 39 | -- |
90 | 2.20.1 | 40 | 2.34.1 |
91 | 41 | ||
92 | 42 | diff view generated by jsdifflib |
1 | The AN524 version of the SCC interface has different behaviour for | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | some of the CFG registers; implement it. | ||
3 | 2 | ||
4 | Each board in this family can have minor differences in the meaning | 3 | "hw/arm/boot.h" is only required on the source file. |
5 | of the CFG registers, so rather than trying to specify all the | ||
6 | possible semantics via individual device properties, we make the | ||
7 | behaviour conditional on the part-number field of the SCC_ID register | ||
8 | which the board code already passes us. | ||
9 | 4 | ||
10 | For the AN524, the differences are: | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | * CFG3 is reserved rather than being board switches | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | * CFG5 is a new register ("ACLK Frequency in Hz") | 7 | Reviewed-by: Luc Michel <luc.michel@amd.com> |
13 | * CFG6 is a new register ("Clock divider for BRAM") | 8 | Message-id: 20231025065316.56817-9-philmd@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/fsl-imx7.h | 1 - | ||
12 | hw/arm/mcimx7d-sabre.c | 1 + | ||
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
14 | 14 | ||
15 | We implement both of the new registers as reads-as-written. | 15 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210215115138.20465-11-peter.maydell@linaro.org | ||
20 | --- | ||
21 | include/hw/misc/mps2-scc.h | 3 ++ | ||
22 | hw/misc/mps2-scc.c | 71 ++++++++++++++++++++++++++++++++++++-- | ||
23 | 2 files changed, 72 insertions(+), 2 deletions(-) | ||
24 | |||
25 | diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/misc/mps2-scc.h | 17 | --- a/include/hw/arm/fsl-imx7.h |
28 | +++ b/include/hw/misc/mps2-scc.h | 18 | +++ b/include/hw/arm/fsl-imx7.h |
29 | @@ -XXX,XX +XXX,XX @@ struct MPS2SCC { | 19 | @@ -XXX,XX +XXX,XX @@ |
30 | 20 | #ifndef FSL_IMX7_H | |
31 | uint32_t cfg0; | 21 | #define FSL_IMX7_H |
32 | uint32_t cfg1; | 22 | |
33 | + uint32_t cfg2; | 23 | -#include "hw/arm/boot.h" |
34 | uint32_t cfg4; | 24 | #include "hw/cpu/a15mpcore.h" |
35 | + uint32_t cfg5; | 25 | #include "hw/intc/imx_gpcv2.h" |
36 | + uint32_t cfg6; | 26 | #include "hw/misc/imx7_ccm.h" |
37 | uint32_t cfgdata_rtn; | 27 | diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c |
38 | uint32_t cfgdata_out; | ||
39 | uint32_t cfgctrl; | ||
40 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/misc/mps2-scc.c | 29 | --- a/hw/arm/mcimx7d-sabre.c |
43 | +++ b/hw/misc/mps2-scc.c | 30 | +++ b/hw/arm/mcimx7d-sabre.c |
44 | @@ -XXX,XX +XXX,XX @@ | 31 | @@ -XXX,XX +XXX,XX @@ |
45 | 32 | #include "qemu/osdep.h" | |
46 | REG32(CFG0, 0) | 33 | #include "qapi/error.h" |
47 | REG32(CFG1, 4) | 34 | #include "hw/arm/fsl-imx7.h" |
48 | +REG32(CFG2, 8) | 35 | +#include "hw/arm/boot.h" |
49 | REG32(CFG3, 0xc) | 36 | #include "hw/boards.h" |
50 | REG32(CFG4, 0x10) | 37 | #include "hw/qdev-properties.h" |
51 | +REG32(CFG5, 0x14) | 38 | #include "qemu/error-report.h" |
52 | +REG32(CFG6, 0x18) | ||
53 | REG32(CFGDATA_RTN, 0xa0) | ||
54 | REG32(CFGDATA_OUT, 0xa4) | ||
55 | REG32(CFGCTRL, 0xa8) | ||
56 | @@ -XXX,XX +XXX,XX @@ REG32(DLL, 0x100) | ||
57 | REG32(AID, 0xFF8) | ||
58 | REG32(ID, 0xFFC) | ||
59 | |||
60 | +static int scc_partno(MPS2SCC *s) | ||
61 | +{ | ||
62 | + /* Return the partno field of the SCC_ID (0x524, 0x511, etc) */ | ||
63 | + return extract32(s->id, 4, 8); | ||
64 | +} | ||
65 | + | ||
66 | /* Handle a write via the SYS_CFG channel to the specified function/device. | ||
67 | * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit). | ||
68 | */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | ||
70 | case A_CFG1: | ||
71 | r = s->cfg1; | ||
72 | break; | ||
73 | + case A_CFG2: | ||
74 | + if (scc_partno(s) != 0x524) { | ||
75 | + /* CFG2 reserved on other boards */ | ||
76 | + goto bad_offset; | ||
77 | + } | ||
78 | + r = s->cfg2; | ||
79 | + break; | ||
80 | case A_CFG3: | ||
81 | + if (scc_partno(s) == 0x524) { | ||
82 | + /* CFG3 reserved on AN524 */ | ||
83 | + goto bad_offset; | ||
84 | + } | ||
85 | /* These are user-settable DIP switches on the board. We don't | ||
86 | * model that, so just return zeroes. | ||
87 | */ | ||
88 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | ||
89 | case A_CFG4: | ||
90 | r = s->cfg4; | ||
91 | break; | ||
92 | + case A_CFG5: | ||
93 | + if (scc_partno(s) != 0x524) { | ||
94 | + /* CFG5 reserved on other boards */ | ||
95 | + goto bad_offset; | ||
96 | + } | ||
97 | + r = s->cfg5; | ||
98 | + break; | ||
99 | + case A_CFG6: | ||
100 | + if (scc_partno(s) != 0x524) { | ||
101 | + /* CFG6 reserved on other boards */ | ||
102 | + goto bad_offset; | ||
103 | + } | ||
104 | + r = s->cfg6; | ||
105 | + break; | ||
106 | case A_CFGDATA_RTN: | ||
107 | r = s->cfgdata_rtn; | ||
108 | break; | ||
109 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | ||
110 | r = s->id; | ||
111 | break; | ||
112 | default: | ||
113 | + bad_offset: | ||
114 | qemu_log_mask(LOG_GUEST_ERROR, | ||
115 | "MPS2 SCC read: bad offset %x\n", (int) offset); | ||
116 | r = 0; | ||
117 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, | ||
118 | led_set_state(s->led[i], extract32(value, i, 1)); | ||
119 | } | ||
120 | break; | ||
121 | + case A_CFG2: | ||
122 | + if (scc_partno(s) != 0x524) { | ||
123 | + /* CFG2 reserved on other boards */ | ||
124 | + goto bad_offset; | ||
125 | + } | ||
126 | + /* AN524: QSPI Select signal */ | ||
127 | + s->cfg2 = value; | ||
128 | + break; | ||
129 | + case A_CFG5: | ||
130 | + if (scc_partno(s) != 0x524) { | ||
131 | + /* CFG5 reserved on other boards */ | ||
132 | + goto bad_offset; | ||
133 | + } | ||
134 | + /* AN524: ACLK frequency in Hz */ | ||
135 | + s->cfg5 = value; | ||
136 | + break; | ||
137 | + case A_CFG6: | ||
138 | + if (scc_partno(s) != 0x524) { | ||
139 | + /* CFG6 reserved on other boards */ | ||
140 | + goto bad_offset; | ||
141 | + } | ||
142 | + /* AN524: Clock divider for BRAM */ | ||
143 | + s->cfg6 = value; | ||
144 | + break; | ||
145 | case A_CFGDATA_OUT: | ||
146 | s->cfgdata_out = value; | ||
147 | break; | ||
148 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, | ||
149 | s->dll = deposit32(s->dll, 24, 8, extract32(value, 24, 8)); | ||
150 | break; | ||
151 | default: | ||
152 | + bad_offset: | ||
153 | qemu_log_mask(LOG_GUEST_ERROR, | ||
154 | "MPS2 SCC write: bad offset 0x%x\n", (int) offset); | ||
155 | break; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_reset(DeviceState *dev) | ||
157 | trace_mps2_scc_reset(); | ||
158 | s->cfg0 = 0; | ||
159 | s->cfg1 = 0; | ||
160 | + s->cfg2 = 0; | ||
161 | + s->cfg5 = 0; | ||
162 | + s->cfg6 = 0; | ||
163 | s->cfgdata_rtn = 0; | ||
164 | s->cfgdata_out = 0; | ||
165 | s->cfgctrl = 0x100000; | ||
166 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_realize(DeviceState *dev, Error **errp) | ||
167 | |||
168 | static const VMStateDescription mps2_scc_vmstate = { | ||
169 | .name = "mps2-scc", | ||
170 | - .version_id = 2, | ||
171 | - .minimum_version_id = 2, | ||
172 | + .version_id = 3, | ||
173 | + .minimum_version_id = 3, | ||
174 | .fields = (VMStateField[]) { | ||
175 | VMSTATE_UINT32(cfg0, MPS2SCC), | ||
176 | VMSTATE_UINT32(cfg1, MPS2SCC), | ||
177 | + VMSTATE_UINT32(cfg2, MPS2SCC), | ||
178 | + /* cfg3, cfg4 are read-only so need not be migrated */ | ||
179 | + VMSTATE_UINT32(cfg5, MPS2SCC), | ||
180 | + VMSTATE_UINT32(cfg6, MPS2SCC), | ||
181 | VMSTATE_UINT32(cfgdata_rtn, MPS2SCC), | ||
182 | VMSTATE_UINT32(cfgdata_out, MPS2SCC), | ||
183 | VMSTATE_UINT32(cfgctrl, MPS2SCC), | ||
184 | -- | 39 | -- |
185 | 2.20.1 | 40 | 2.34.1 |
186 | 41 | ||
187 | 42 | diff view generated by jsdifflib |
1 | The AN524 has more interrupt lines than the AN505 and AN521; make | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | numirq board-specific rather than a compile-time constant. | ||
3 | 2 | ||
4 | Since the difference is small (92 on the current boards and 95 on the | 3 | "hw/arm/boot.h" is only required on the source file. |
5 | new one) we don't dynamically allocate the cpu_irq_splitter[] array | ||
6 | but leave it as a fixed length array whose size is the maximum needed | ||
7 | for any of the boards. | ||
8 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
8 | Message-id: 20231025065316.56817-10-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210215115138.20465-10-peter.maydell@linaro.org | ||
13 | --- | 10 | --- |
14 | hw/arm/mps2-tz.c | 15 ++++++++++----- | 11 | include/hw/arm/xlnx-versal.h | 1 - |
15 | 1 file changed, 10 insertions(+), 5 deletions(-) | 12 | hw/arm/xlnx-versal-virt.c | 1 + |
13 | 2 files changed, 1 insertion(+), 1 deletion(-) | ||
16 | 14 | ||
17 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/mps2-tz.c | 17 | --- a/include/hw/arm/xlnx-versal.h |
20 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/include/hw/arm/xlnx-versal.h |
21 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | #include "hw/qdev-clock.h" | 20 | #define XLNX_VERSAL_H |
21 | |||
22 | #include "hw/sysbus.h" | ||
23 | -#include "hw/arm/boot.h" | ||
24 | #include "hw/cpu/cluster.h" | ||
25 | #include "hw/or-irq.h" | ||
26 | #include "hw/sd/sdhci.h" | ||
27 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/arm/xlnx-versal-virt.c | ||
30 | +++ b/hw/arm/xlnx-versal-virt.c | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | #include "cpu.h" | ||
33 | #include "hw/qdev-properties.h" | ||
34 | #include "hw/arm/xlnx-versal.h" | ||
35 | +#include "hw/arm/boot.h" | ||
23 | #include "qom/object.h" | 36 | #include "qom/object.h" |
24 | 37 | ||
25 | -#define MPS2TZ_NUMIRQ 92 | 38 | #define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt") |
26 | +#define MPS2TZ_NUMIRQ_MAX 92 | ||
27 | |||
28 | typedef enum MPS2TZFPGAType { | ||
29 | FPGA_AN505, | ||
30 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | ||
31 | const uint32_t *oscclk; | ||
32 | uint32_t fpgaio_num_leds; /* Number of LEDs in FPGAIO LED0 register */ | ||
33 | bool fpgaio_has_switches; /* Does FPGAIO have SWITCH register? */ | ||
34 | + int numirq; /* Number of external interrupts */ | ||
35 | const char *armsse_type; | ||
36 | }; | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | ||
39 | SplitIRQ sec_resp_splitter; | ||
40 | qemu_or_irq uart_irq_orgate; | ||
41 | DeviceState *lan9118; | ||
42 | - SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ]; | ||
43 | + SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ_MAX]; | ||
44 | Clock *sysclk; | ||
45 | Clock *s32kclk; | ||
46 | }; | ||
47 | @@ -XXX,XX +XXX,XX @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) | ||
48 | { | ||
49 | /* Return a qemu_irq which will signal IRQ n to all CPUs in the SSE. */ | ||
50 | MachineClass *mc = MACHINE_GET_CLASS(mms); | ||
51 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
52 | |||
53 | - assert(irqno < MPS2TZ_NUMIRQ); | ||
54 | + assert(irqno < mmc->numirq); | ||
55 | |||
56 | if (mc->max_cpus > 1) { | ||
57 | return qdev_get_gpio_in(DEVICE(&mms->cpu_irq_splitter[irqno]), 0); | ||
58 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
59 | iotkitdev = DEVICE(&mms->iotkit); | ||
60 | object_property_set_link(OBJECT(&mms->iotkit), "memory", | ||
61 | OBJECT(system_memory), &error_abort); | ||
62 | - qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); | ||
63 | + qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", mmc->numirq); | ||
64 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); | ||
65 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); | ||
66 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
68 | * board. If there is only one CPU, we can just wire the device IRQ | ||
69 | * directly to the SSE's IRQ input. | ||
70 | */ | ||
71 | + assert(mmc->numirq <= MPS2TZ_NUMIRQ_MAX); | ||
72 | if (mc->max_cpus > 1) { | ||
73 | - for (i = 0; i < MPS2TZ_NUMIRQ; i++) { | ||
74 | + for (i = 0; i < mmc->numirq; i++) { | ||
75 | char *name = g_strdup_printf("mps2-irq-splitter%d", i); | ||
76 | SplitIRQ *splitter = &mms->cpu_irq_splitter[i]; | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | ||
79 | mmc->len_oscclk = ARRAY_SIZE(an505_oscclk); | ||
80 | mmc->fpgaio_num_leds = 2; | ||
81 | mmc->fpgaio_has_switches = false; | ||
82 | + mmc->numirq = 92; | ||
83 | mmc->armsse_type = TYPE_IOTKIT; | ||
84 | } | ||
85 | |||
86 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
87 | mmc->len_oscclk = ARRAY_SIZE(an505_oscclk); | ||
88 | mmc->fpgaio_num_leds = 2; | ||
89 | mmc->fpgaio_has_switches = false; | ||
90 | + mmc->numirq = 92; | ||
91 | mmc->armsse_type = TYPE_SSE200; | ||
92 | } | ||
93 | |||
94 | -- | 39 | -- |
95 | 2.20.1 | 40 | 2.34.1 |
96 | 41 | ||
97 | 42 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We hint the 'has_rpu' property is no longer required since commit | 3 | "hw/arm/boot.h" is only required on the source file. |
4 | 6908ec448b4 ("xlnx-zynqmp: Properly support the smp command line | ||
5 | option") which was released in QEMU v2.11.0. | ||
6 | 4 | ||
7 | Beside, this device is marked 'user_creatable = false', so the | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | only thing that could be setting the property is the board code | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | that creates the device. | 7 | Reviewed-by: Luc Michel <luc.michel@amd.com> |
10 | 8 | Message-id: 20231025065316.56817-11-philmd@linaro.org | |
11 | Since the property is not user-facing, we can remove it without | ||
12 | going through the deprecation process. | ||
13 | |||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-id: 20210219144350.1979905-1-f4bug@amsat.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 10 | --- |
19 | include/hw/arm/xlnx-zynqmp.h | 2 -- | 11 | include/hw/arm/xlnx-zynqmp.h | 1 - |
20 | hw/arm/xlnx-zynqmp.c | 6 ------ | 12 | hw/arm/xlnx-zcu102.c | 1 + |
21 | 2 files changed, 8 deletions(-) | 13 | 2 files changed, 1 insertion(+), 1 deletion(-) |
22 | 14 | ||
23 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | 15 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/xlnx-zynqmp.h | 17 | --- a/include/hw/arm/xlnx-zynqmp.h |
26 | +++ b/include/hw/arm/xlnx-zynqmp.h | 18 | +++ b/include/hw/arm/xlnx-zynqmp.h |
27 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | 19 | @@ -XXX,XX +XXX,XX @@ |
28 | bool secure; | 20 | #ifndef XLNX_ZYNQMP_H |
29 | /* Has the ARM Virtualization extensions? */ | 21 | #define XLNX_ZYNQMP_H |
30 | bool virt; | 22 | |
31 | - /* Has the RPU subsystem? */ | 23 | -#include "hw/arm/boot.h" |
32 | - bool has_rpu; | 24 | #include "hw/intc/arm_gic.h" |
33 | 25 | #include "hw/net/cadence_gem.h" | |
34 | /* CAN bus. */ | 26 | #include "hw/char/cadence_uart.h" |
35 | CanBusState *canbus[XLNX_ZYNQMP_NUM_CAN]; | 27 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c |
36 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/xlnx-zynqmp.c | 29 | --- a/hw/arm/xlnx-zcu102.c |
39 | +++ b/hw/arm/xlnx-zynqmp.c | 30 | +++ b/hw/arm/xlnx-zcu102.c |
40 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 31 | @@ -XXX,XX +XXX,XX @@ |
41 | } | 32 | #include "qemu/osdep.h" |
42 | } | 33 | #include "qapi/error.h" |
43 | 34 | #include "hw/arm/xlnx-zynqmp.h" | |
44 | - if (s->has_rpu) { | 35 | +#include "hw/arm/boot.h" |
45 | - info_report("The 'has_rpu' property is no longer required, to use the " | 36 | #include "hw/boards.h" |
46 | - "RPUs just use -smp 6."); | 37 | #include "qemu/error-report.h" |
47 | - } | 38 | #include "qemu/log.h" |
48 | - | ||
49 | xlnx_zynqmp_create_rpu(ms, s, boot_cpu, &err); | ||
50 | if (err) { | ||
51 | error_propagate(errp, err); | ||
52 | @@ -XXX,XX +XXX,XX @@ static Property xlnx_zynqmp_props[] = { | ||
53 | DEFINE_PROP_STRING("boot-cpu", XlnxZynqMPState, boot_cpu), | ||
54 | DEFINE_PROP_BOOL("secure", XlnxZynqMPState, secure, false), | ||
55 | DEFINE_PROP_BOOL("virtualization", XlnxZynqMPState, virt, false), | ||
56 | - DEFINE_PROP_BOOL("has_rpu", XlnxZynqMPState, has_rpu, false), | ||
57 | DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState, ddr_ram, TYPE_MEMORY_REGION, | ||
58 | MemoryRegion *), | ||
59 | DEFINE_PROP_LINK("canbus0", XlnxZynqMPState, canbus[0], TYPE_CAN_BUS, | ||
60 | -- | 39 | -- |
61 | 2.20.1 | 40 | 2.34.1 |
62 | 41 | ||
63 | 42 | diff view generated by jsdifflib |
1 | From: schspa <schspa@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | At the moment the following QEMU command line triggers an assertion | 3 | sysbus_mmio_map() and sysbus_connect_irq() should not be |
4 | failure On xlnx-versal SOC: | 4 | called on unrealized device. |
5 | qemu-system-aarch64 \ | ||
6 | -machine xlnx-versal-virt -nographic -smp 2 -m 128 \ | ||
7 | -fsdev local,id=shareid,path=${HOME}/work,security_model=none \ | ||
8 | -device virtio-9p-device,fsdev=shareid,mount_tag=share \ | ||
9 | -fsdev local,id=shareid1,path=${HOME}/Music,security_model=none \ | ||
10 | -device virtio-9p-device,fsdev=shareid1,mount_tag=share1 | ||
11 | 5 | ||
12 | qemu-system-aarch64: ../migration/savevm.c:860: | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
13 | vmstate_register_with_alias_id: | 7 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
14 | Assertion `!se->compat || se->instance_id == 0' failed. | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | 9 | Message-id: 20231020130331.50048-2-philmd@linaro.org | |
16 | This problem was fixed on arm virt platform in commit f58b39d2d5b | ||
17 | ("virtio-mmio: format transport base address in BusClass.get_dev_path") | ||
18 | |||
19 | It works perfectly on arm virt platform. but there is still there on | ||
20 | xlnx-versal SOC. | ||
21 | |||
22 | The main difference between arm virt and xlnx-versal is they use | ||
23 | different way to create virtio-mmio qdev. on arm virt, it calls | ||
24 | sysbus_create_simple("virtio-mmio", base, pic[irq]); which will call | ||
25 | sysbus_mmio_map internally and assign base address to subsys device | ||
26 | mmio correctly. but xlnx-versal's implements won't do this. | ||
27 | |||
28 | However, xlnx-versal can't switch to sysbus_create_simple() to create | ||
29 | virtio-mmio device. It's because xlnx-versal's cpu use | ||
30 | VersalVirt.soc.fpd.apu.mr as it's memory. which is subregion of | ||
31 | system_memory. sysbus_create_simple will add virtio to system_memory, | ||
32 | which can't be accessed by cpu. | ||
33 | |||
34 | Besides, xlnx-versal can't add sysbus_mmio_map api call too, because | ||
35 | this will add memory region to system_memory, and it can't be added | ||
36 | to VersalVirt.soc.fpd.apu.mr again. | ||
37 | |||
38 | We can solve this by assign correct base address offset on dev_path. | ||
39 | |||
40 | This path was test on aarch64 virt & xlnx-versal platform. | ||
41 | |||
42 | Signed-off-by: schspa <schspa@gmail.com> | ||
43 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
44 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
45 | --- | 11 | --- |
46 | hw/virtio/virtio-mmio.c | 13 +++++++------ | 12 | hw/sd/pxa2xx_mmci.c | 2 +- |
47 | 1 file changed, 7 insertions(+), 6 deletions(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
48 | 14 | ||
49 | diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c | 15 | diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c |
50 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/hw/virtio/virtio-mmio.c | 17 | --- a/hw/sd/pxa2xx_mmci.c |
52 | +++ b/hw/virtio/virtio-mmio.c | 18 | +++ b/hw/sd/pxa2xx_mmci.c |
53 | @@ -XXX,XX +XXX,XX @@ static char *virtio_mmio_bus_get_dev_path(DeviceState *dev) | 19 | @@ -XXX,XX +XXX,XX @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, |
54 | BusState *virtio_mmio_bus; | 20 | |
55 | VirtIOMMIOProxy *virtio_mmio_proxy; | 21 | dev = qdev_new(TYPE_PXA2XX_MMCI); |
56 | char *proxy_path; | 22 | sbd = SYS_BUS_DEVICE(dev); |
57 | - SysBusDevice *proxy_sbd; | 23 | + sysbus_realize_and_unref(sbd, &error_fatal); |
58 | char *path; | 24 | sysbus_mmio_map(sbd, 0, base); |
59 | + MemoryRegionSection section; | 25 | sysbus_connect_irq(sbd, 0, irq); |
60 | 26 | qdev_connect_gpio_out_named(dev, "rx-dma", 0, rx_dma); | |
61 | virtio_mmio_bus = qdev_get_parent_bus(dev); | 27 | qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma); |
62 | virtio_mmio_proxy = VIRTIO_MMIO(virtio_mmio_bus->parent); | 28 | - sysbus_realize_and_unref(sbd, &error_fatal); |
63 | @@ -XXX,XX +XXX,XX @@ static char *virtio_mmio_bus_get_dev_path(DeviceState *dev) | 29 | |
64 | } | 30 | return PXA2XX_MMCI(dev); |
65 | |||
66 | /* Otherwise, we append the base address of the transport. */ | ||
67 | - proxy_sbd = SYS_BUS_DEVICE(virtio_mmio_proxy); | ||
68 | - assert(proxy_sbd->num_mmio == 1); | ||
69 | - assert(proxy_sbd->mmio[0].memory == &virtio_mmio_proxy->iomem); | ||
70 | + section = memory_region_find(&virtio_mmio_proxy->iomem, 0, 0x200); | ||
71 | + assert(section.mr); | ||
72 | |||
73 | if (proxy_path) { | ||
74 | path = g_strdup_printf("%s/virtio-mmio@" TARGET_FMT_plx, proxy_path, | ||
75 | - proxy_sbd->mmio[0].addr); | ||
76 | + section.offset_within_address_space); | ||
77 | } else { | ||
78 | path = g_strdup_printf("virtio-mmio@" TARGET_FMT_plx, | ||
79 | - proxy_sbd->mmio[0].addr); | ||
80 | + section.offset_within_address_space); | ||
81 | } | ||
82 | + memory_region_unref(section.mr); | ||
83 | + | ||
84 | g_free(proxy_path); | ||
85 | return path; | ||
86 | } | 31 | } |
87 | -- | 32 | -- |
88 | 2.20.1 | 33 | 2.34.1 |
89 | 34 | ||
90 | 35 | diff view generated by jsdifflib |
1 | The MPS2 board has 2 LEDs, but the MPS3 board has 10 LEDs. The | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | FPGAIO device is similar on both sets of boards, but the LED0 | ||
3 | register has correspondingly more bits that have an effect. Add a | ||
4 | device property for number of LEDs. | ||
5 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20231020130331.50048-3-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210215115138.20465-6-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | include/hw/misc/mps2-fpgaio.h | 5 ++++- | 9 | hw/sd/pxa2xx_mmci.c | 7 +------ |
12 | hw/misc/mps2-fpgaio.c | 31 +++++++++++++++++++++++-------- | 10 | 1 file changed, 1 insertion(+), 6 deletions(-) |
13 | 2 files changed, 27 insertions(+), 9 deletions(-) | ||
14 | 11 | ||
15 | diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h | 12 | diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c |
16 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/misc/mps2-fpgaio.h | 14 | --- a/hw/sd/pxa2xx_mmci.c |
18 | +++ b/include/hw/misc/mps2-fpgaio.h | 15 | +++ b/hw/sd/pxa2xx_mmci.c |
19 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, |
20 | #define TYPE_MPS2_FPGAIO "mps2-fpgaio" | 17 | qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma) |
21 | OBJECT_DECLARE_SIMPLE_TYPE(MPS2FPGAIO, MPS2_FPGAIO) | ||
22 | |||
23 | +#define MPS2FPGAIO_MAX_LEDS 32 | ||
24 | + | ||
25 | struct MPS2FPGAIO { | ||
26 | /*< private >*/ | ||
27 | SysBusDevice parent_obj; | ||
28 | |||
29 | /*< public >*/ | ||
30 | MemoryRegion iomem; | ||
31 | - LEDState *led[2]; | ||
32 | + LEDState *led[MPS2FPGAIO_MAX_LEDS]; | ||
33 | + uint32_t num_leds; | ||
34 | |||
35 | uint32_t led0; | ||
36 | uint32_t prescale; | ||
37 | diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/misc/mps2-fpgaio.c | ||
40 | +++ b/hw/misc/mps2-fpgaio.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value, | ||
42 | |||
43 | switch (offset) { | ||
44 | case A_LED0: | ||
45 | - s->led0 = value & 0x3; | ||
46 | - led_set_state(s->led[0], value & 0x01); | ||
47 | - led_set_state(s->led[1], value & 0x02); | ||
48 | + if (s->num_leds != 0) { | ||
49 | + uint32_t i; | ||
50 | + | ||
51 | + s->led0 = value & MAKE_64BIT_MASK(0, s->num_leds); | ||
52 | + for (i = 0; i < s->num_leds; i++) { | ||
53 | + led_set_state(s->led[i], value & (1 << i)); | ||
54 | + } | ||
55 | + } | ||
56 | break; | ||
57 | case A_PRESCALE: | ||
58 | resync_counter(s); | ||
59 | @@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_reset(DeviceState *dev) | ||
60 | s->pscntr = 0; | ||
61 | s->pscntr_sync_ticks = now; | ||
62 | |||
63 | - for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) { | ||
64 | + for (size_t i = 0; i < s->num_leds; i++) { | ||
65 | device_cold_reset(DEVICE(s->led[i])); | ||
66 | } | ||
67 | } | ||
68 | @@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_init(Object *obj) | ||
69 | static void mps2_fpgaio_realize(DeviceState *dev, Error **errp) | ||
70 | { | 18 | { |
71 | MPS2FPGAIO *s = MPS2_FPGAIO(dev); | 19 | DeviceState *dev; |
72 | + uint32_t i; | 20 | - SysBusDevice *sbd; |
73 | 21 | ||
74 | - s->led[0] = led_create_simple(OBJECT(dev), GPIO_POLARITY_ACTIVE_HIGH, | 22 | - dev = qdev_new(TYPE_PXA2XX_MMCI); |
75 | - LED_COLOR_GREEN, "USERLED0"); | 23 | - sbd = SYS_BUS_DEVICE(dev); |
76 | - s->led[1] = led_create_simple(OBJECT(dev), GPIO_POLARITY_ACTIVE_HIGH, | 24 | - sysbus_realize_and_unref(sbd, &error_fatal); |
77 | - LED_COLOR_GREEN, "USERLED1"); | 25 | - sysbus_mmio_map(sbd, 0, base); |
78 | + if (s->num_leds > MPS2FPGAIO_MAX_LEDS) { | 26 | - sysbus_connect_irq(sbd, 0, irq); |
79 | + error_setg(errp, "num-leds cannot be greater than %d", | 27 | + dev = sysbus_create_simple(TYPE_PXA2XX_MMCI, base, irq); |
80 | + MPS2FPGAIO_MAX_LEDS); | 28 | qdev_connect_gpio_out_named(dev, "rx-dma", 0, rx_dma); |
81 | + return; | 29 | qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma); |
82 | + } | ||
83 | + | ||
84 | + for (i = 0; i < s->num_leds; i++) { | ||
85 | + g_autofree char *ledname = g_strdup_printf("USERLED%d", i); | ||
86 | + s->led[i] = led_create_simple(OBJECT(dev), GPIO_POLARITY_ACTIVE_HIGH, | ||
87 | + LED_COLOR_GREEN, ledname); | ||
88 | + } | ||
89 | } | ||
90 | |||
91 | static bool mps2_fpgaio_counters_needed(void *opaque) | ||
92 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription mps2_fpgaio_vmstate = { | ||
93 | static Property mps2_fpgaio_properties[] = { | ||
94 | /* Frequency of the prescale counter */ | ||
95 | DEFINE_PROP_UINT32("prescale-clk", MPS2FPGAIO, prescale_clk, 20000000), | ||
96 | + /* Number of LEDs controlled by LED0 register */ | ||
97 | + DEFINE_PROP_UINT32("num-leds", MPS2FPGAIO, num_leds, 2), | ||
98 | DEFINE_PROP_END_OF_LIST(), | ||
99 | }; | ||
100 | 30 | ||
101 | -- | 31 | -- |
102 | 2.20.1 | 32 | 2.34.1 |
103 | 33 | ||
104 | 34 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The STATUS register will be reset to IDLE in | 3 | sysbus_mmio_map() should not be called on unrealized device. |
4 | cnpcm7xx_smbus_enter_reset(), no need to preset | ||
5 | it in instance_init(). | ||
6 | 4 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Hao Wu <wuhaotsh@google.com> | 6 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
9 | Message-id: 20210228224813.312532-1-f4bug@amsat.org | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20231020130331.50048-4-philmd@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | hw/i2c/npcm7xx_smbus.c | 1 - | 11 | hw/pcmcia/pxa2xx.c | 7 ++----- |
13 | 1 file changed, 1 deletion(-) | 12 | 1 file changed, 2 insertions(+), 5 deletions(-) |
14 | 13 | ||
15 | diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c | 14 | diff --git a/hw/pcmcia/pxa2xx.c b/hw/pcmcia/pxa2xx.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/i2c/npcm7xx_smbus.c | 16 | --- a/hw/pcmcia/pxa2xx.c |
18 | +++ b/hw/i2c/npcm7xx_smbus.c | 17 | +++ b/hw/pcmcia/pxa2xx.c |
19 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_smbus_init(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, |
20 | sysbus_init_mmio(sbd, &s->iomem); | 19 | hwaddr base) |
21 | 20 | { | |
22 | s->bus = i2c_init_bus(DEVICE(s), "i2c-bus"); | 21 | DeviceState *dev; |
23 | - s->status = NPCM7XX_SMBUS_STATUS_IDLE; | 22 | - PXA2xxPCMCIAState *s; |
23 | |||
24 | dev = qdev_new(TYPE_PXA2XX_PCMCIA); | ||
25 | - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
26 | - s = PXA2XX_PCMCIA(dev); | ||
27 | - | ||
28 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
29 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
30 | |||
31 | - return s; | ||
32 | + return PXA2XX_PCMCIA(dev); | ||
24 | } | 33 | } |
25 | 34 | ||
26 | static const VMStateDescription vmstate_npcm7xx_smbus = { | 35 | static void pxa2xx_pcmcia_initfn(Object *obj) |
27 | -- | 36 | -- |
28 | 2.20.1 | 37 | 2.34.1 |
29 | 38 | ||
30 | 39 | diff view generated by jsdifflib |
1 | From: Rebecca Cran <rebecca@nuviainc.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Enable FEAT_SSBS for the "max" 32-bit CPU. | 3 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
4 | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
5 | Signed-off-by: Rebecca Cran <rebecca@nuviainc.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210216224543.16142-4-rebecca@nuviainc.com | 6 | Message-id: 20231020130331.50048-5-philmd@linaro.org |
8 | [PMM: fix typo causing compilation failure] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | target/arm/cpu.c | 4 ++++ | 9 | hw/pcmcia/pxa2xx.c | 4 +--- |
12 | 1 file changed, 4 insertions(+) | 10 | 1 file changed, 1 insertion(+), 3 deletions(-) |
13 | 11 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 12 | diff --git a/hw/pcmcia/pxa2xx.c b/hw/pcmcia/pxa2xx.c |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 14 | --- a/hw/pcmcia/pxa2xx.c |
17 | +++ b/target/arm/cpu.c | 15 | +++ b/hw/pcmcia/pxa2xx.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, |
19 | t = cpu->isar.id_pfr0; | 17 | { |
20 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); | 18 | DeviceState *dev; |
21 | cpu->isar.id_pfr0 = t; | 19 | |
22 | + | 20 | - dev = qdev_new(TYPE_PXA2XX_PCMCIA); |
23 | + t = cpu->isar.id_pfr2; | 21 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
24 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | 22 | - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
25 | + cpu->isar.id_pfr2 = t; | 23 | + dev = sysbus_create_simple(TYPE_PXA2XX_PCMCIA, base, NULL); |
26 | } | 24 | |
27 | #endif | 25 | return PXA2XX_PCMCIA(dev); |
28 | } | 26 | } |
29 | -- | 27 | -- |
30 | 2.20.1 | 28 | 2.34.1 |
31 | 29 | ||
32 | 30 | diff view generated by jsdifflib |
1 | The AN505 and AN521 don't have any read-only memory, but the AN524 | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | does; add a flag to ROMInfo to mark a region as ROM. | ||
3 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20231020130331.50048-6-philmd@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210215115138.20465-19-peter.maydell@linaro.org | ||
7 | --- | 8 | --- |
8 | hw/arm/mps2-tz.c | 6 ++++++ | 9 | include/hw/arm/pxa.h | 2 -- |
9 | 1 file changed, 6 insertions(+) | 10 | hw/arm/pxa2xx.c | 12 ++++++++---- |
11 | hw/pcmcia/pxa2xx.c | 10 ---------- | ||
12 | 3 files changed, 8 insertions(+), 16 deletions(-) | ||
10 | 13 | ||
11 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 14 | diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/mps2-tz.c | 16 | --- a/include/hw/arm/pxa.h |
14 | +++ b/hw/arm/mps2-tz.c | 17 | +++ b/include/hw/arm/pxa.h |
15 | @@ -XXX,XX +XXX,XX @@ typedef struct RAMInfo { | 18 | @@ -XXX,XX +XXX,XX @@ void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly, |
16 | * Flag values: | 19 | #define TYPE_PXA2XX_PCMCIA "pxa2xx-pcmcia" |
17 | * IS_ALIAS: this RAM area is an alias to the upstream end of the | 20 | OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxPCMCIAState, PXA2XX_PCMCIA) |
18 | * MPC specified by its .mpc value | 21 | |
19 | + * IS_ROM: this RAM area is read-only | 22 | -PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, |
20 | */ | 23 | - hwaddr base); |
21 | #define IS_ALIAS 1 | 24 | int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card); |
22 | +#define IS_ROM 2 | 25 | int pxa2xx_pcmcia_detach(void *opaque); |
23 | 26 | void pxa2xx_pcmcia_set_irq_cb(void *opaque, qemu_irq irq, qemu_irq cd_irq); | |
24 | struct MPS2TZMachineClass { | 27 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
25 | MachineClass parent; | 28 | index XXXXXXX..XXXXXXX 100644 |
26 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *mr_for_raminfo(MPS2TZMachineState *mms, | 29 | --- a/hw/arm/pxa2xx.c |
27 | if (raminfo->mrindex < 0) { | 30 | +++ b/hw/arm/pxa2xx.c |
28 | /* Means this RAMInfo is for QEMU's "system memory" */ | 31 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *cpu_type) |
29 | MachineState *machine = MACHINE(mms); | 32 | sysbus_create_simple("sysbus-ohci", 0x4c000000, |
30 | + assert(!(raminfo->flags & IS_ROM)); | 33 | qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1)); |
31 | return machine->ram; | 34 | |
35 | - s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000); | ||
36 | - s->pcmcia[1] = pxa2xx_pcmcia_init(address_space, 0x30000000); | ||
37 | + s->pcmcia[0] = PXA2XX_PCMCIA(sysbus_create_simple(TYPE_PXA2XX_PCMCIA, | ||
38 | + 0x20000000, NULL)); | ||
39 | + s->pcmcia[1] = PXA2XX_PCMCIA(sysbus_create_simple(TYPE_PXA2XX_PCMCIA, | ||
40 | + 0x30000000, NULL)); | ||
41 | |||
42 | sysbus_create_simple(TYPE_PXA2XX_RTC, 0x40900000, | ||
43 | qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM)); | ||
44 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa255_init(unsigned int sdram_size) | ||
45 | s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); | ||
32 | } | 46 | } |
33 | 47 | ||
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *mr_for_raminfo(MPS2TZMachineState *mms, | 48 | - s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000); |
35 | 49 | - s->pcmcia[1] = pxa2xx_pcmcia_init(address_space, 0x30000000); | |
36 | memory_region_init_ram(ram, NULL, raminfo->name, | 50 | + s->pcmcia[0] = PXA2XX_PCMCIA(sysbus_create_simple(TYPE_PXA2XX_PCMCIA, |
37 | raminfo->size, &error_fatal); | 51 | + 0x20000000, NULL)); |
38 | + if (raminfo->flags & IS_ROM) { | 52 | + s->pcmcia[1] = PXA2XX_PCMCIA(sysbus_create_simple(TYPE_PXA2XX_PCMCIA, |
39 | + memory_region_set_readonly(ram, true); | 53 | + 0x30000000, NULL)); |
40 | + } | 54 | |
41 | return ram; | 55 | sysbus_create_simple(TYPE_PXA2XX_RTC, 0x40900000, |
56 | qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM)); | ||
57 | diff --git a/hw/pcmcia/pxa2xx.c b/hw/pcmcia/pxa2xx.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/pcmcia/pxa2xx.c | ||
60 | +++ b/hw/pcmcia/pxa2xx.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pcmcia_set_irq(void *opaque, int line, int level) | ||
62 | qemu_set_irq(s->irq, level); | ||
42 | } | 63 | } |
43 | 64 | ||
65 | -PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem, | ||
66 | - hwaddr base) | ||
67 | -{ | ||
68 | - DeviceState *dev; | ||
69 | - | ||
70 | - dev = sysbus_create_simple(TYPE_PXA2XX_PCMCIA, base, NULL); | ||
71 | - | ||
72 | - return PXA2XX_PCMCIA(dev); | ||
73 | -} | ||
74 | - | ||
75 | static void pxa2xx_pcmcia_initfn(Object *obj) | ||
76 | { | ||
77 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
44 | -- | 78 | -- |
45 | 2.20.1 | 79 | 2.34.1 |
46 | 80 | ||
47 | 81 | diff view generated by jsdifflib |
1 | The armv7m_load_kernel() function takes a mem_size argument which it | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | expects to be the size of the memory region at guest address 0. (It | ||
3 | uses this argument only as a limit on how large a raw image file it | ||
4 | can load at address zero). | ||
5 | 2 | ||
6 | Instead of hardcoding this value, find the RAMInfo corresponding to | 3 | Factor reset code out of the DeviceRealize() handler. |
7 | the 0 address and extract its size. | ||
8 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
8 | Message-id: 20231020130331.50048-7-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210215115138.20465-20-peter.maydell@linaro.org | ||
13 | --- | 10 | --- |
14 | hw/arm/mps2-tz.c | 17 ++++++++++++++++- | 11 | hw/arm/pxa2xx_pic.c | 17 ++++++++++++----- |
15 | 1 file changed, 16 insertions(+), 1 deletion(-) | 12 | 1 file changed, 12 insertions(+), 5 deletions(-) |
16 | 13 | ||
17 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 14 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/mps2-tz.c | 16 | --- a/hw/arm/pxa2xx_pic.c |
20 | +++ b/hw/arm/mps2-tz.c | 17 | +++ b/hw/arm/pxa2xx_pic.c |
21 | @@ -XXX,XX +XXX,XX @@ static void create_non_mpc_ram(MPS2TZMachineState *mms) | 18 | @@ -XXX,XX +XXX,XX @@ static int pxa2xx_pic_post_load(void *opaque, int version_id) |
22 | } | 19 | return 0; |
23 | } | 20 | } |
24 | 21 | ||
25 | +static uint32_t boot_ram_size(MPS2TZMachineState *mms) | 22 | -DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu) |
26 | +{ | 23 | +static void pxa2xx_pic_reset_hold(Object *obj) |
27 | + /* Return the size of the RAM block at guest address zero */ | 24 | { |
28 | + const RAMInfo *p; | 25 | - DeviceState *dev = qdev_new(TYPE_PXA2XX_PIC); |
29 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 26 | - PXA2xxPICState *s = PXA2XX_PIC(dev); |
30 | + | 27 | - |
31 | + for (p = mmc->raminfo; p->name; p++) { | 28 | - s->cpu = cpu; |
32 | + if (p->base == 0) { | 29 | + PXA2xxPICState *s = PXA2XX_PIC(obj); |
33 | + return p->size; | 30 | |
34 | + } | 31 | s->int_pending[0] = 0; |
35 | + } | 32 | s->int_pending[1] = 0; |
36 | + g_assert_not_reached(); | 33 | @@ -XXX,XX +XXX,XX @@ DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu) |
34 | s->int_enabled[1] = 0; | ||
35 | s->is_fiq[0] = 0; | ||
36 | s->is_fiq[1] = 0; | ||
37 | +} | 37 | +} |
38 | + | 38 | + |
39 | static void mps2tz_common_init(MachineState *machine) | 39 | +DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu) |
40 | +{ | ||
41 | + DeviceState *dev = qdev_new(TYPE_PXA2XX_PIC); | ||
42 | + PXA2xxPICState *s = PXA2XX_PIC(dev); | ||
43 | + | ||
44 | + s->cpu = cpu; | ||
45 | |||
46 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pxa2xx_pic_regs = { | ||
49 | static void pxa2xx_pic_class_init(ObjectClass *klass, void *data) | ||
40 | { | 50 | { |
41 | MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine); | 51 | DeviceClass *dc = DEVICE_CLASS(klass); |
42 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 52 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
43 | 53 | ||
44 | create_non_mpc_ram(mms); | 54 | dc->desc = "PXA2xx PIC"; |
45 | 55 | dc->vmsd = &vmstate_pxa2xx_pic_regs; | |
46 | - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x400000); | 56 | + rc->phases.hold = pxa2xx_pic_reset_hold; |
47 | + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, | ||
48 | + boot_ram_size(mms)); | ||
49 | } | 57 | } |
50 | 58 | ||
51 | static void mps2_tz_idau_check(IDAUInterface *ii, uint32_t address, | 59 | static const TypeInfo pxa2xx_pic_info = { |
52 | -- | 60 | -- |
53 | 2.20.1 | 61 | 2.34.1 |
54 | 62 | ||
55 | 63 | diff view generated by jsdifflib |
1 | The AN505 and AN511 happen to share the same OSCCLK values, but the | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | AN524 will have a different set (and more of them), so split the | ||
3 | settings out to be per-board. | ||
4 | 2 | ||
3 | QOM objects shouldn't access each other internals fields | ||
4 | except using the QOM API. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
9 | Message-id: 20231020130331.50048-8-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210215115138.20465-5-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | hw/arm/mps2-tz.c | 23 ++++++++++++++++++----- | 12 | hw/arm/pxa2xx_pic.c | 11 ++++++++++- |
11 | 1 file changed, 18 insertions(+), 5 deletions(-) | 13 | 1 file changed, 10 insertions(+), 1 deletion(-) |
12 | 14 | ||
13 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/mps2-tz.c | 17 | --- a/hw/arm/pxa2xx_pic.c |
16 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/hw/arm/pxa2xx_pic.c |
17 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | 19 | @@ -XXX,XX +XXX,XX @@ |
18 | MPS2TZFPGAType fpga_type; | 20 | #include "cpu.h" |
19 | uint32_t scc_id; | 21 | #include "hw/arm/pxa.h" |
20 | uint32_t sysclk_frq; /* Main SYSCLK frequency in Hz */ | 22 | #include "hw/sysbus.h" |
21 | + uint32_t len_oscclk; | 23 | +#include "hw/qdev-properties.h" |
22 | + const uint32_t *oscclk; | 24 | #include "migration/vmstate.h" |
23 | const char *armsse_type; | 25 | #include "qom/object.h" |
26 | #include "target/arm/cpregs.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu) | ||
28 | DeviceState *dev = qdev_new(TYPE_PXA2XX_PIC); | ||
29 | PXA2xxPICState *s = PXA2XX_PIC(dev); | ||
30 | |||
31 | - s->cpu = cpu; | ||
32 | + object_property_set_link(OBJECT(dev), "arm-cpu", | ||
33 | + OBJECT(cpu), &error_abort); | ||
34 | |||
35 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pxa2xx_pic_regs = { | ||
38 | }, | ||
24 | }; | 39 | }; |
25 | 40 | ||
26 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | 41 | +static Property pxa2xx_pic_properties[] = { |
27 | /* Slow 32Khz S32KCLK frequency in Hz */ | 42 | + DEFINE_PROP_LINK("arm-cpu", PXA2xxPICState, cpu, |
28 | #define S32KCLK_FRQ (32 * 1000) | 43 | + TYPE_ARM_CPU, ARMCPU *), |
29 | 44 | + DEFINE_PROP_END_OF_LIST(), | |
30 | +static const uint32_t an505_oscclk[] = { | ||
31 | + 40000000, | ||
32 | + 24580000, | ||
33 | + 25000000, | ||
34 | +}; | 45 | +}; |
35 | + | 46 | + |
36 | /* Create an alias of an entire original MemoryRegion @orig | 47 | static void pxa2xx_pic_class_init(ObjectClass *klass, void *data) |
37 | * located at @base in the memory map. | 48 | { |
38 | */ | 49 | DeviceClass *dc = DEVICE_CLASS(klass); |
39 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | 50 | ResettableClass *rc = RESETTABLE_CLASS(klass); |
40 | MPS2SCC *scc = opaque; | 51 | |
41 | DeviceState *sccdev; | 52 | + device_class_set_props(dc, pxa2xx_pic_properties); |
42 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 53 | dc->desc = "PXA2xx PIC"; |
43 | + uint32_t i; | 54 | dc->vmsd = &vmstate_pxa2xx_pic_regs; |
44 | 55 | rc->phases.hold = pxa2xx_pic_reset_hold; | |
45 | object_initialize_child(OBJECT(mms), "scc", scc, TYPE_MPS2_SCC); | ||
46 | sccdev = DEVICE(scc); | ||
47 | qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); | ||
48 | qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); | ||
49 | qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | ||
50 | - /* This will need to be per-FPGA image eventually */ | ||
51 | - qdev_prop_set_uint32(sccdev, "len-oscclk", 3); | ||
52 | - qdev_prop_set_uint32(sccdev, "oscclk[0]", 40000000); | ||
53 | - qdev_prop_set_uint32(sccdev, "oscclk[1]", 24580000); | ||
54 | - qdev_prop_set_uint32(sccdev, "oscclk[2]", 25000000); | ||
55 | + qdev_prop_set_uint32(sccdev, "len-oscclk", mmc->len_oscclk); | ||
56 | + for (i = 0; i < mmc->len_oscclk; i++) { | ||
57 | + g_autofree char *propname = g_strdup_printf("oscclk[%u]", i); | ||
58 | + qdev_prop_set_uint32(sccdev, propname, mmc->oscclk[i]); | ||
59 | + } | ||
60 | sysbus_realize(SYS_BUS_DEVICE(scc), &error_fatal); | ||
61 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(sccdev), 0); | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | ||
64 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | ||
65 | mmc->scc_id = 0x41045050; | ||
66 | mmc->sysclk_frq = 20 * 1000 * 1000; /* 20MHz */ | ||
67 | + mmc->oscclk = an505_oscclk; | ||
68 | + mmc->len_oscclk = ARRAY_SIZE(an505_oscclk); | ||
69 | mmc->armsse_type = TYPE_IOTKIT; | ||
70 | } | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
73 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | ||
74 | mmc->scc_id = 0x41045210; | ||
75 | mmc->sysclk_frq = 20 * 1000 * 1000; /* 20MHz */ | ||
76 | + mmc->oscclk = an505_oscclk; /* AN521 is the same as AN505 here */ | ||
77 | + mmc->len_oscclk = ARRAY_SIZE(an505_oscclk); | ||
78 | mmc->armsse_type = TYPE_SSE200; | ||
79 | } | ||
80 | |||
81 | -- | 56 | -- |
82 | 2.20.1 | 57 | 2.34.1 |
83 | 58 | ||
84 | 59 | diff view generated by jsdifflib |
1 | Instead of hardcoding the MachineClass default_ram_size and | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | default_ram_id fields, set them on class creation by finding the | ||
3 | entry in the RAMInfo array which is marked as being the QEMU system | ||
4 | RAM. | ||
5 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
6 | Message-id: 20231020130331.50048-9-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210215115138.20465-18-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | hw/arm/mps2-tz.c | 24 ++++++++++++++++++++++-- | 9 | hw/arm/pxa2xx_pic.c | 16 ++++++++++------ |
11 | 1 file changed, 22 insertions(+), 2 deletions(-) | 10 | 1 file changed, 10 insertions(+), 6 deletions(-) |
12 | 11 | ||
13 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 12 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/mps2-tz.c | 14 | --- a/hw/arm/pxa2xx_pic.c |
16 | +++ b/hw/arm/mps2-tz.c | 15 | +++ b/hw/arm/pxa2xx_pic.c |
17 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_class_init(ObjectClass *oc, void *data) | 16 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pic_reset_hold(Object *obj) |
18 | 17 | DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu) | |
19 | mc->init = mps2tz_common_init; | 18 | { |
20 | iic->check = mps2_tz_idau_check; | 19 | DeviceState *dev = qdev_new(TYPE_PXA2XX_PIC); |
21 | - mc->default_ram_size = 16 * MiB; | 20 | - PXA2xxPICState *s = PXA2XX_PIC(dev); |
22 | - mc->default_ram_id = "mps.ram"; | 21 | |
22 | object_property_set_link(OBJECT(dev), "arm-cpu", | ||
23 | OBJECT(cpu), &error_abort); | ||
24 | - | ||
25 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
26 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
27 | + | ||
28 | + return dev; | ||
23 | +} | 29 | +} |
24 | + | 30 | + |
25 | +static void mps2tz_set_default_ram_info(MPS2TZMachineClass *mmc) | 31 | +static void pxa2xx_pic_realize(DeviceState *dev, Error **errp) |
26 | +{ | 32 | +{ |
27 | + /* | 33 | + PXA2xxPICState *s = PXA2XX_PIC(dev); |
28 | + * Set mc->default_ram_size and default_ram_id from the | 34 | |
29 | + * information in mmc->raminfo. | 35 | qdev_init_gpio_in(dev, pxa2xx_pic_set_irq, PXA2XX_PIC_SRCS); |
30 | + */ | 36 | |
31 | + MachineClass *mc = MACHINE_CLASS(mmc); | 37 | @@ -XXX,XX +XXX,XX @@ DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu) |
32 | + const RAMInfo *p; | 38 | memory_region_init_io(&s->iomem, OBJECT(s), &pxa2xx_pic_ops, s, |
33 | + | 39 | "pxa2xx-pic", 0x00100000); |
34 | + for (p = mmc->raminfo; p->name; p++) { | 40 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); |
35 | + if (p->mrindex < 0) { | 41 | - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
36 | + /* Found the entry for "system memory" */ | 42 | |
37 | + mc->default_ram_size = p->size; | 43 | /* Enable IC coprocessor access. */ |
38 | + mc->default_ram_id = p->name; | 44 | - define_arm_cp_regs_with_opaque(cpu, pxa_pic_cp_reginfo, s); |
39 | + return; | 45 | - |
40 | + } | 46 | - return dev; |
41 | + } | 47 | + define_arm_cp_regs_with_opaque(s->cpu, pxa_pic_cp_reginfo, s); |
42 | + g_assert_not_reached(); | ||
43 | } | 48 | } |
44 | 49 | ||
45 | static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | 50 | static const VMStateDescription vmstate_pxa2xx_pic_regs = { |
46 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | 51 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pic_class_init(ObjectClass *klass, void *data) |
47 | mmc->numirq = 92; | 52 | ResettableClass *rc = RESETTABLE_CLASS(klass); |
48 | mmc->raminfo = an505_raminfo; | 53 | |
49 | mmc->armsse_type = TYPE_IOTKIT; | 54 | device_class_set_props(dc, pxa2xx_pic_properties); |
50 | + mps2tz_set_default_ram_info(mmc); | 55 | + dc->realize = pxa2xx_pic_realize; |
51 | } | 56 | dc->desc = "PXA2xx PIC"; |
52 | 57 | dc->vmsd = &vmstate_pxa2xx_pic_regs; | |
53 | static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | 58 | rc->phases.hold = pxa2xx_pic_reset_hold; |
54 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
55 | mmc->numirq = 92; | ||
56 | mmc->raminfo = an505_raminfo; /* AN521 is the same as AN505 here */ | ||
57 | mmc->armsse_type = TYPE_SSE200; | ||
58 | + mps2tz_set_default_ram_info(mmc); | ||
59 | } | ||
60 | |||
61 | static const TypeInfo mps2tz_info = { | ||
62 | -- | 59 | -- |
63 | 2.20.1 | 60 | 2.34.1 |
64 | 61 | ||
65 | 62 | diff view generated by jsdifflib |
1 | We were previously using the default OSCCLK settings, which are | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | correct for the older MPS2 boards (mps2-an385, mps2-an386, | ||
3 | mps2-an500, mps2-an511), but wrong for the mps2-an505 and mps2-511 | ||
4 | implemented in mps2-tz.c. Now we're setting the values explicitly we | ||
5 | can fix them to be correct. | ||
6 | 2 | ||
3 | qbus_new(), called in i2c_init_bus(), should not be called | ||
4 | on unrealized device. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
9 | Message-id: 20231020130331.50048-10-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210215115138.20465-4-peter.maydell@linaro.org | ||
11 | --- | 11 | --- |
12 | hw/arm/mps2-tz.c | 4 ++-- | 12 | hw/arm/pxa2xx.c | 5 +++-- |
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 3 insertions(+), 2 deletions(-) |
14 | 14 | ||
15 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 15 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/mps2-tz.c | 17 | --- a/hw/arm/pxa2xx.c |
18 | +++ b/hw/arm/mps2-tz.c | 18 | +++ b/hw/arm/pxa2xx.c |
19 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | 19 | @@ -XXX,XX +XXX,XX @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base, |
20 | qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | 20 | qdev_prop_set_uint32(dev, "size", region_size + 1); |
21 | /* This will need to be per-FPGA image eventually */ | 21 | qdev_prop_set_uint32(dev, "offset", base & region_size); |
22 | qdev_prop_set_uint32(sccdev, "len-oscclk", 3); | 22 | |
23 | - qdev_prop_set_uint32(sccdev, "oscclk[0]", 50000000); | 23 | + /* FIXME: Should the slave device really be on a separate bus? */ |
24 | - qdev_prop_set_uint32(sccdev, "oscclk[1]", 24576000); | 24 | + i2cbus = i2c_init_bus(dev, "dummy"); |
25 | + qdev_prop_set_uint32(sccdev, "oscclk[0]", 40000000); | 25 | + |
26 | + qdev_prop_set_uint32(sccdev, "oscclk[1]", 24580000); | 26 | i2c_dev = SYS_BUS_DEVICE(dev); |
27 | qdev_prop_set_uint32(sccdev, "oscclk[2]", 25000000); | 27 | sysbus_realize_and_unref(i2c_dev, &error_fatal); |
28 | sysbus_realize(SYS_BUS_DEVICE(scc), &error_fatal); | 28 | sysbus_mmio_map(i2c_dev, 0, base & ~region_size); |
29 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(sccdev), 0); | 29 | sysbus_connect_irq(i2c_dev, 0, irq); |
30 | |||
31 | s = PXA2XX_I2C(i2c_dev); | ||
32 | - /* FIXME: Should the slave device really be on a separate bus? */ | ||
33 | - i2cbus = i2c_init_bus(dev, "dummy"); | ||
34 | s->slave = PXA2XX_I2C_SLAVE(i2c_slave_create_simple(i2cbus, | ||
35 | TYPE_PXA2XX_I2C_SLAVE, | ||
36 | 0)); | ||
30 | -- | 37 | -- |
31 | 2.20.1 | 38 | 2.34.1 |
32 | 39 | ||
33 | 40 | diff view generated by jsdifflib |
1 | The mps2-tz code uses PPCPortInfo data structures to define what | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | devices are present and how they are wired up. Currently we use | ||
3 | these to specify device types and addresses, but hard-code the | ||
4 | interrupt line wiring in each make_* helper function. This works for | ||
5 | the two boards we have at the moment, but the AN524 has some devices | ||
6 | with different interrupt assignments. | ||
7 | 2 | ||
8 | This commit adds the framework to allow PPCPortInfo structures to | 3 | Prefer using a well known local first CPU rather than a global one. |
9 | specify interrupt numbers. We add an array of interrupt numbers to | ||
10 | the PPCPortInfo struct, and pass it through to the make_* helpers. | ||
11 | The following commit will change the make_* helpers over to using the | ||
12 | framework. | ||
13 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20231025065909.57344-1-philmd@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20210215115138.20465-13-peter.maydell@linaro.org | ||
17 | --- | 9 | --- |
18 | hw/arm/mps2-tz.c | 36 ++++++++++++++++++++++++------------ | 10 | hw/arm/bananapi_m2u.c | 2 +- |
19 | 1 file changed, 24 insertions(+), 12 deletions(-) | 11 | hw/arm/exynos4_boards.c | 7 ++++--- |
12 | hw/arm/orangepi.c | 2 +- | ||
13 | hw/arm/realview.c | 2 +- | ||
14 | hw/arm/xilinx_zynq.c | 2 +- | ||
15 | 5 files changed, 8 insertions(+), 7 deletions(-) | ||
20 | 16 | ||
21 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 17 | diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c |
22 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/arm/mps2-tz.c | 19 | --- a/hw/arm/bananapi_m2u.c |
24 | +++ b/hw/arm/mps2-tz.c | 20 | +++ b/hw/arm/bananapi_m2u.c |
25 | @@ -XXX,XX +XXX,XX @@ static qemu_irq get_sse_irq_in(MPS2TZMachineState *mms, int irqno) | 21 | @@ -XXX,XX +XXX,XX @@ static void bpim2u_init(MachineState *machine) |
26 | * needs to be plugged into the downstream end of the PPC port. | 22 | bpim2u_binfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM]; |
27 | */ | 23 | bpim2u_binfo.ram_size = machine->ram_size; |
28 | typedef MemoryRegion *MakeDevFn(MPS2TZMachineState *mms, void *opaque, | 24 | bpim2u_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC; |
29 | - const char *name, hwaddr size); | 25 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &bpim2u_binfo); |
30 | + const char *name, hwaddr size, | 26 | + arm_load_kernel(&r40->cpus[0], machine, &bpim2u_binfo); |
31 | + const int *irqs); | 27 | } |
32 | 28 | ||
33 | typedef struct PPCPortInfo { | 29 | static void bpim2u_machine_init(MachineClass *mc) |
34 | const char *name; | 30 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c |
35 | @@ -XXX,XX +XXX,XX @@ typedef struct PPCPortInfo { | 31 | index XXXXXXX..XXXXXXX 100644 |
36 | void *opaque; | 32 | --- a/hw/arm/exynos4_boards.c |
37 | hwaddr addr; | 33 | +++ b/hw/arm/exynos4_boards.c |
38 | hwaddr size; | 34 | @@ -XXX,XX +XXX,XX @@ exynos4_boards_init_common(MachineState *machine, |
39 | + int irqs[3]; /* currently no device needs more IRQ lines than this */ | 35 | |
40 | } PPCPortInfo; | 36 | static void nuri_init(MachineState *machine) |
41 | |||
42 | typedef struct PPCInfo { | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef struct PPCInfo { | ||
44 | } PPCInfo; | ||
45 | |||
46 | static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | ||
47 | - void *opaque, | ||
48 | - const char *name, hwaddr size) | ||
49 | + void *opaque, | ||
50 | + const char *name, hwaddr size, | ||
51 | + const int *irqs) | ||
52 | { | 37 | { |
53 | /* Initialize, configure and realize a TYPE_UNIMPLEMENTED_DEVICE, | 38 | - exynos4_boards_init_common(machine, EXYNOS4_BOARD_NURI); |
54 | * and return a pointer to its MemoryRegion. | 39 | + Exynos4BoardState *s = exynos4_boards_init_common(machine, |
55 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | 40 | + EXYNOS4_BOARD_NURI); |
41 | |||
42 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &exynos4_board_binfo); | ||
43 | + arm_load_kernel(s->soc.cpu[0], machine, &exynos4_board_binfo); | ||
56 | } | 44 | } |
57 | 45 | ||
58 | static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | 46 | static void smdkc210_init(MachineState *machine) |
59 | - const char *name, hwaddr size) | 47 | @@ -XXX,XX +XXX,XX @@ static void smdkc210_init(MachineState *machine) |
60 | + const char *name, hwaddr size, | 48 | |
61 | + const int *irqs) | 49 | lan9215_init(SMDK_LAN9118_BASE_ADDR, |
62 | { | 50 | qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)])); |
63 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 51 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &exynos4_board_binfo); |
64 | CMSDKAPBUART *uart = opaque; | 52 | + arm_load_kernel(s->soc.cpu[0], machine, &exynos4_board_binfo); |
65 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
66 | } | 53 | } |
67 | 54 | ||
68 | static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | 55 | static void nuri_class_init(ObjectClass *oc, void *data) |
69 | - const char *name, hwaddr size) | 56 | diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c |
70 | + const char *name, hwaddr size, | 57 | index XXXXXXX..XXXXXXX 100644 |
71 | + const int *irqs) | 58 | --- a/hw/arm/orangepi.c |
72 | { | 59 | +++ b/hw/arm/orangepi.c |
73 | MPS2SCC *scc = opaque; | 60 | @@ -XXX,XX +XXX,XX @@ static void orangepi_init(MachineState *machine) |
74 | DeviceState *sccdev; | 61 | orangepi_binfo.loader_start = h3->memmap[AW_H3_DEV_SDRAM]; |
75 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | 62 | orangepi_binfo.ram_size = machine->ram_size; |
63 | orangepi_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC; | ||
64 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &orangepi_binfo); | ||
65 | + arm_load_kernel(&h3->cpus[0], machine, &orangepi_binfo); | ||
76 | } | 66 | } |
77 | 67 | ||
78 | static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms, void *opaque, | 68 | static void orangepi_machine_init(MachineClass *mc) |
79 | - const char *name, hwaddr size) | 69 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c |
80 | + const char *name, hwaddr size, | 70 | index XXXXXXX..XXXXXXX 100644 |
81 | + const int *irqs) | 71 | --- a/hw/arm/realview.c |
82 | { | 72 | +++ b/hw/arm/realview.c |
83 | MPS2FPGAIO *fpgaio = opaque; | 73 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, |
84 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | 74 | realview_binfo.ram_size = ram_size; |
85 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms, void *opaque, | 75 | realview_binfo.board_id = realview_board_id[board_type]; |
76 | realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0); | ||
77 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &realview_binfo); | ||
78 | + arm_load_kernel(cpu, machine, &realview_binfo); | ||
86 | } | 79 | } |
87 | 80 | ||
88 | static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | 81 | static void realview_eb_init(MachineState *machine) |
89 | - const char *name, hwaddr size) | 82 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c |
90 | + const char *name, hwaddr size, | 83 | index XXXXXXX..XXXXXXX 100644 |
91 | + const int *irqs) | 84 | --- a/hw/arm/xilinx_zynq.c |
92 | { | 85 | +++ b/hw/arm/xilinx_zynq.c |
93 | SysBusDevice *s; | 86 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) |
94 | NICInfo *nd = &nd_table[0]; | 87 | zynq_binfo.board_setup_addr = BOARD_SETUP_ADDR; |
95 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | 88 | zynq_binfo.write_board_setup = zynq_write_board_setup; |
89 | |||
90 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &zynq_binfo); | ||
91 | + arm_load_kernel(cpu, machine, &zynq_binfo); | ||
96 | } | 92 | } |
97 | 93 | ||
98 | static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | 94 | static void zynq_machine_class_init(ObjectClass *oc, void *data) |
99 | - const char *name, hwaddr size) | ||
100 | + const char *name, hwaddr size, | ||
101 | + const int *irqs) | ||
102 | { | ||
103 | TZMPC *mpc = opaque; | ||
104 | int i = mpc - &mms->ssram_mpc[0]; | ||
105 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | ||
106 | } | ||
107 | |||
108 | static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | ||
109 | - const char *name, hwaddr size) | ||
110 | + const char *name, hwaddr size, | ||
111 | + const int *irqs) | ||
112 | { | ||
113 | PL080State *dma = opaque; | ||
114 | int i = dma - &mms->dma[0]; | ||
115 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | ||
116 | } | ||
117 | |||
118 | static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque, | ||
119 | - const char *name, hwaddr size) | ||
120 | + const char *name, hwaddr size, | ||
121 | + const int *irqs) | ||
122 | { | ||
123 | /* | ||
124 | * The AN505 has five PL022 SPI controllers. | ||
125 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque, | ||
126 | } | ||
127 | |||
128 | static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, | ||
129 | - const char *name, hwaddr size) | ||
130 | + const char *name, hwaddr size, | ||
131 | + const int *irqs) | ||
132 | { | ||
133 | ArmSbconI2CState *i2c = opaque; | ||
134 | SysBusDevice *s; | ||
135 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
136 | continue; | ||
137 | } | ||
138 | |||
139 | - mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size); | ||
140 | + mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size, | ||
141 | + pinfo->irqs); | ||
142 | portname = g_strdup_printf("port[%d]", port); | ||
143 | object_property_set_link(OBJECT(ppc), portname, OBJECT(mr), | ||
144 | &error_fatal); | ||
145 | -- | 95 | -- |
146 | 2.20.1 | 96 | 2.34.1 |
147 | 97 | ||
148 | 98 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Glenn Miles <milesg@linux.vnet.ibm.com> |
---|---|---|---|
2 | 2 | ||
3 | We will move this code in the next commit. Clean it up | 3 | Testing of the LED state showed that when the LED polarity was |
4 | first to avoid checkpatch.pl errors. | 4 | set to GPIO_POLARITY_ACTIVE_LOW and a low logic value was set on |
5 | the input GPIO of the LED, the LED was being turn off when it was | ||
6 | expected to be turned on. | ||
5 | 7 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Fixes: ddb67f6402 ("hw/misc/led: Allow connecting from GPIO output") |
7 | Message-id: 20210221222617.2579610-3-f4bug@amsat.org | 9 | Signed-off-by: Glenn Miles <milesg@linux.vnet.ibm.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au> | ||
12 | Message-id: 20231024191945.4135036-1-milesg@linux.vnet.ibm.com | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 15 | --- |
11 | target/arm/cpu.c | 12 ++++++++---- | 16 | hw/misc/led.c | 2 +- |
12 | 1 file changed, 8 insertions(+), 4 deletions(-) | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 18 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 19 | diff --git a/hw/misc/led.c b/hw/misc/led.c |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 21 | --- a/hw/misc/led.c |
17 | +++ b/target/arm/cpu.c | 22 | +++ b/hw/misc/led.c |
18 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | 23 | @@ -XXX,XX +XXX,XX @@ static void led_set_state_gpio_handler(void *opaque, int line, int new_state) |
24 | LEDState *s = LED(opaque); | ||
25 | |||
26 | assert(line == 0); | ||
27 | - led_set_state(s, !!new_state != s->gpio_active_high); | ||
28 | + led_set_state(s, !!new_state == s->gpio_active_high); | ||
19 | } | 29 | } |
20 | 30 | ||
21 | static const ARMCPRegInfo cortexa9_cp_reginfo[] = { | 31 | static void led_reset(DeviceState *dev) |
22 | - /* power_control should be set to maximum latency. Again, | ||
23 | + /* | ||
24 | + * power_control should be set to maximum latency. Again, | ||
25 | * default to 0 and set by private hook | ||
26 | */ | ||
27 | { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
28 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
29 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
30 | set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); | ||
31 | set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
32 | - /* Note that A9 supports the MP extensions even for | ||
33 | + /* | ||
34 | + * Note that A9 supports the MP extensions even for | ||
35 | * A9UP and single-core A9MP (which are both different | ||
36 | * and valid configurations; we don't model A9UP). | ||
37 | */ | ||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
39 | { | ||
40 | MachineState *ms = MACHINE(qdev_get_machine()); | ||
41 | |||
42 | - /* Linux wants the number of processors from here. | ||
43 | + /* | ||
44 | + * Linux wants the number of processors from here. | ||
45 | * Might as well set the interrupt-controller bit too. | ||
46 | */ | ||
47 | return ((ms->smp.cpus - 1) << 24) | (1 << 23); | ||
48 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
49 | cpu->isar.id_mmfr1 = 0x40000000; | ||
50 | cpu->isar.id_mmfr2 = 0x01240000; | ||
51 | cpu->isar.id_mmfr3 = 0x02102211; | ||
52 | - /* a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but | ||
53 | + /* | ||
54 | + * a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but | ||
55 | * table 4-41 gives 0x02101110, which includes the arm div insns. | ||
56 | */ | ||
57 | cpu->isar.id_isar0 = 0x02101110; | ||
58 | -- | 32 | -- |
59 | 2.20.1 | 33 | 2.34.1 |
60 | 34 | ||
61 | 35 | diff view generated by jsdifflib |
1 | Currently the MPS2 SCC device implements a fixed number of OSCCLK | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | values (3). The variant of this device in the MPS3 AN524 board has 6 | ||
3 | OSCCLK values. Switch to using a PROP_ARRAY, which allows board code | ||
4 | to specify how large the OSCCLK array should be as well as its | ||
5 | values. | ||
6 | 2 | ||
7 | With a variable-length property array, the SCC no longer specifies | 3 | Replace register defines with the REG32 macro from registerfields.h in |
8 | default values for the OSCCLKs, so we must set them explicitly in the | 4 | the Cadence GEM device. |
9 | board code. This defaults are actually incorrect for the an521 and | ||
10 | an505; we will correct this bug in a following patch. | ||
11 | 5 | ||
12 | This is a migration compatibility break for all the mps boards. | 6 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
7 | Reviewed-by: sai.pavan.boddu@amd.com | ||
8 | Message-id: 20231017194422.4124691-2-luc.michel@amd.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/net/cadence_gem.c | 527 +++++++++++++++++++++---------------------- | ||
12 | 1 file changed, 261 insertions(+), 266 deletions(-) | ||
13 | 13 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20210215115138.20465-3-peter.maydell@linaro.org | ||
18 | --- | ||
19 | include/hw/misc/mps2-scc.h | 7 +++---- | ||
20 | hw/arm/mps2-tz.c | 5 +++++ | ||
21 | hw/arm/mps2.c | 5 +++++ | ||
22 | hw/misc/mps2-scc.c | 24 +++++++++++++----------- | ||
23 | 4 files changed, 26 insertions(+), 15 deletions(-) | ||
24 | |||
25 | diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/misc/mps2-scc.h | 16 | --- a/hw/net/cadence_gem.c |
28 | +++ b/include/hw/misc/mps2-scc.h | 17 | +++ b/hw/net/cadence_gem.c |
29 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
30 | #define TYPE_MPS2_SCC "mps2-scc" | 19 | #include "hw/irq.h" |
31 | OBJECT_DECLARE_SIMPLE_TYPE(MPS2SCC, MPS2_SCC) | 20 | #include "hw/net/cadence_gem.h" |
32 | 21 | #include "hw/qdev-properties.h" | |
33 | -#define NUM_OSCCLK 3 | 22 | +#include "hw/registerfields.h" |
23 | #include "migration/vmstate.h" | ||
24 | #include "qapi/error.h" | ||
25 | #include "qemu/log.h" | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | } \ | ||
28 | } while (0) | ||
29 | |||
30 | -#define GEM_NWCTRL (0x00000000 / 4) /* Network Control reg */ | ||
31 | -#define GEM_NWCFG (0x00000004 / 4) /* Network Config reg */ | ||
32 | -#define GEM_NWSTATUS (0x00000008 / 4) /* Network Status reg */ | ||
33 | -#define GEM_USERIO (0x0000000C / 4) /* User IO reg */ | ||
34 | -#define GEM_DMACFG (0x00000010 / 4) /* DMA Control reg */ | ||
35 | -#define GEM_TXSTATUS (0x00000014 / 4) /* TX Status reg */ | ||
36 | -#define GEM_RXQBASE (0x00000018 / 4) /* RX Q Base address reg */ | ||
37 | -#define GEM_TXQBASE (0x0000001C / 4) /* TX Q Base address reg */ | ||
38 | -#define GEM_RXSTATUS (0x00000020 / 4) /* RX Status reg */ | ||
39 | -#define GEM_ISR (0x00000024 / 4) /* Interrupt Status reg */ | ||
40 | -#define GEM_IER (0x00000028 / 4) /* Interrupt Enable reg */ | ||
41 | -#define GEM_IDR (0x0000002C / 4) /* Interrupt Disable reg */ | ||
42 | -#define GEM_IMR (0x00000030 / 4) /* Interrupt Mask reg */ | ||
43 | -#define GEM_PHYMNTNC (0x00000034 / 4) /* Phy Maintenance reg */ | ||
44 | -#define GEM_RXPAUSE (0x00000038 / 4) /* RX Pause Time reg */ | ||
45 | -#define GEM_TXPAUSE (0x0000003C / 4) /* TX Pause Time reg */ | ||
46 | -#define GEM_TXPARTIALSF (0x00000040 / 4) /* TX Partial Store and Forward */ | ||
47 | -#define GEM_RXPARTIALSF (0x00000044 / 4) /* RX Partial Store and Forward */ | ||
48 | -#define GEM_JUMBO_MAX_LEN (0x00000048 / 4) /* Max Jumbo Frame Size */ | ||
49 | -#define GEM_HASHLO (0x00000080 / 4) /* Hash Low address reg */ | ||
50 | -#define GEM_HASHHI (0x00000084 / 4) /* Hash High address reg */ | ||
51 | -#define GEM_SPADDR1LO (0x00000088 / 4) /* Specific addr 1 low reg */ | ||
52 | -#define GEM_SPADDR1HI (0x0000008C / 4) /* Specific addr 1 high reg */ | ||
53 | -#define GEM_SPADDR2LO (0x00000090 / 4) /* Specific addr 2 low reg */ | ||
54 | -#define GEM_SPADDR2HI (0x00000094 / 4) /* Specific addr 2 high reg */ | ||
55 | -#define GEM_SPADDR3LO (0x00000098 / 4) /* Specific addr 3 low reg */ | ||
56 | -#define GEM_SPADDR3HI (0x0000009C / 4) /* Specific addr 3 high reg */ | ||
57 | -#define GEM_SPADDR4LO (0x000000A0 / 4) /* Specific addr 4 low reg */ | ||
58 | -#define GEM_SPADDR4HI (0x000000A4 / 4) /* Specific addr 4 high reg */ | ||
59 | -#define GEM_TIDMATCH1 (0x000000A8 / 4) /* Type ID1 Match reg */ | ||
60 | -#define GEM_TIDMATCH2 (0x000000AC / 4) /* Type ID2 Match reg */ | ||
61 | -#define GEM_TIDMATCH3 (0x000000B0 / 4) /* Type ID3 Match reg */ | ||
62 | -#define GEM_TIDMATCH4 (0x000000B4 / 4) /* Type ID4 Match reg */ | ||
63 | -#define GEM_WOLAN (0x000000B8 / 4) /* Wake on LAN reg */ | ||
64 | -#define GEM_IPGSTRETCH (0x000000BC / 4) /* IPG Stretch reg */ | ||
65 | -#define GEM_SVLAN (0x000000C0 / 4) /* Stacked VLAN reg */ | ||
66 | -#define GEM_MODID (0x000000FC / 4) /* Module ID reg */ | ||
67 | -#define GEM_OCTTXLO (0x00000100 / 4) /* Octets transmitted Low reg */ | ||
68 | -#define GEM_OCTTXHI (0x00000104 / 4) /* Octets transmitted High reg */ | ||
69 | -#define GEM_TXCNT (0x00000108 / 4) /* Error-free Frames transmitted */ | ||
70 | -#define GEM_TXBCNT (0x0000010C / 4) /* Error-free Broadcast Frames */ | ||
71 | -#define GEM_TXMCNT (0x00000110 / 4) /* Error-free Multicast Frame */ | ||
72 | -#define GEM_TXPAUSECNT (0x00000114 / 4) /* Pause Frames Transmitted */ | ||
73 | -#define GEM_TX64CNT (0x00000118 / 4) /* Error-free 64 TX */ | ||
74 | -#define GEM_TX65CNT (0x0000011C / 4) /* Error-free 65-127 TX */ | ||
75 | -#define GEM_TX128CNT (0x00000120 / 4) /* Error-free 128-255 TX */ | ||
76 | -#define GEM_TX256CNT (0x00000124 / 4) /* Error-free 256-511 */ | ||
77 | -#define GEM_TX512CNT (0x00000128 / 4) /* Error-free 512-1023 TX */ | ||
78 | -#define GEM_TX1024CNT (0x0000012C / 4) /* Error-free 1024-1518 TX */ | ||
79 | -#define GEM_TX1519CNT (0x00000130 / 4) /* Error-free larger than 1519 TX */ | ||
80 | -#define GEM_TXURUNCNT (0x00000134 / 4) /* TX under run error counter */ | ||
81 | -#define GEM_SINGLECOLLCNT (0x00000138 / 4) /* Single Collision Frames */ | ||
82 | -#define GEM_MULTCOLLCNT (0x0000013C / 4) /* Multiple Collision Frames */ | ||
83 | -#define GEM_EXCESSCOLLCNT (0x00000140 / 4) /* Excessive Collision Frames */ | ||
84 | -#define GEM_LATECOLLCNT (0x00000144 / 4) /* Late Collision Frames */ | ||
85 | -#define GEM_DEFERTXCNT (0x00000148 / 4) /* Deferred Transmission Frames */ | ||
86 | -#define GEM_CSENSECNT (0x0000014C / 4) /* Carrier Sense Error Counter */ | ||
87 | -#define GEM_OCTRXLO (0x00000150 / 4) /* Octets Received register Low */ | ||
88 | -#define GEM_OCTRXHI (0x00000154 / 4) /* Octets Received register High */ | ||
89 | -#define GEM_RXCNT (0x00000158 / 4) /* Error-free Frames Received */ | ||
90 | -#define GEM_RXBROADCNT (0x0000015C / 4) /* Error-free Broadcast Frames RX */ | ||
91 | -#define GEM_RXMULTICNT (0x00000160 / 4) /* Error-free Multicast Frames RX */ | ||
92 | -#define GEM_RXPAUSECNT (0x00000164 / 4) /* Pause Frames Received Counter */ | ||
93 | -#define GEM_RX64CNT (0x00000168 / 4) /* Error-free 64 byte Frames RX */ | ||
94 | -#define GEM_RX65CNT (0x0000016C / 4) /* Error-free 65-127B Frames RX */ | ||
95 | -#define GEM_RX128CNT (0x00000170 / 4) /* Error-free 128-255B Frames RX */ | ||
96 | -#define GEM_RX256CNT (0x00000174 / 4) /* Error-free 256-512B Frames RX */ | ||
97 | -#define GEM_RX512CNT (0x00000178 / 4) /* Error-free 512-1023B Frames RX */ | ||
98 | -#define GEM_RX1024CNT (0x0000017C / 4) /* Error-free 1024-1518B Frames RX */ | ||
99 | -#define GEM_RX1519CNT (0x00000180 / 4) /* Error-free 1519-max Frames RX */ | ||
100 | -#define GEM_RXUNDERCNT (0x00000184 / 4) /* Undersize Frames Received */ | ||
101 | -#define GEM_RXOVERCNT (0x00000188 / 4) /* Oversize Frames Received */ | ||
102 | -#define GEM_RXJABCNT (0x0000018C / 4) /* Jabbers Received Counter */ | ||
103 | -#define GEM_RXFCSCNT (0x00000190 / 4) /* Frame Check seq. Error Counter */ | ||
104 | -#define GEM_RXLENERRCNT (0x00000194 / 4) /* Length Field Error Counter */ | ||
105 | -#define GEM_RXSYMERRCNT (0x00000198 / 4) /* Symbol Error Counter */ | ||
106 | -#define GEM_RXALIGNERRCNT (0x0000019C / 4) /* Alignment Error Counter */ | ||
107 | -#define GEM_RXRSCERRCNT (0x000001A0 / 4) /* Receive Resource Error Counter */ | ||
108 | -#define GEM_RXORUNCNT (0x000001A4 / 4) /* Receive Overrun Counter */ | ||
109 | -#define GEM_RXIPCSERRCNT (0x000001A8 / 4) /* IP header Checksum Err Counter */ | ||
110 | -#define GEM_RXTCPCCNT (0x000001AC / 4) /* TCP Checksum Error Counter */ | ||
111 | -#define GEM_RXUDPCCNT (0x000001B0 / 4) /* UDP Checksum Error Counter */ | ||
112 | +REG32(NWCTRL, 0x0) /* Network Control reg */ | ||
113 | +REG32(NWCFG, 0x4) /* Network Config reg */ | ||
114 | +REG32(NWSTATUS, 0x8) /* Network Status reg */ | ||
115 | +REG32(USERIO, 0xc) /* User IO reg */ | ||
116 | +REG32(DMACFG, 0x10) /* DMA Control reg */ | ||
117 | +REG32(TXSTATUS, 0x14) /* TX Status reg */ | ||
118 | +REG32(RXQBASE, 0x18) /* RX Q Base address reg */ | ||
119 | +REG32(TXQBASE, 0x1c) /* TX Q Base address reg */ | ||
120 | +REG32(RXSTATUS, 0x20) /* RX Status reg */ | ||
121 | +REG32(ISR, 0x24) /* Interrupt Status reg */ | ||
122 | +REG32(IER, 0x28) /* Interrupt Enable reg */ | ||
123 | +REG32(IDR, 0x2c) /* Interrupt Disable reg */ | ||
124 | +REG32(IMR, 0x30) /* Interrupt Mask reg */ | ||
125 | +REG32(PHYMNTNC, 0x34) /* Phy Maintenance reg */ | ||
126 | +REG32(RXPAUSE, 0x38) /* RX Pause Time reg */ | ||
127 | +REG32(TXPAUSE, 0x3c) /* TX Pause Time reg */ | ||
128 | +REG32(TXPARTIALSF, 0x40) /* TX Partial Store and Forward */ | ||
129 | +REG32(RXPARTIALSF, 0x44) /* RX Partial Store and Forward */ | ||
130 | +REG32(JUMBO_MAX_LEN, 0x48) /* Max Jumbo Frame Size */ | ||
131 | +REG32(HASHLO, 0x80) /* Hash Low address reg */ | ||
132 | +REG32(HASHHI, 0x84) /* Hash High address reg */ | ||
133 | +REG32(SPADDR1LO, 0x88) /* Specific addr 1 low reg */ | ||
134 | +REG32(SPADDR1HI, 0x8c) /* Specific addr 1 high reg */ | ||
135 | +REG32(SPADDR2LO, 0x90) /* Specific addr 2 low reg */ | ||
136 | +REG32(SPADDR2HI, 0x94) /* Specific addr 2 high reg */ | ||
137 | +REG32(SPADDR3LO, 0x98) /* Specific addr 3 low reg */ | ||
138 | +REG32(SPADDR3HI, 0x9c) /* Specific addr 3 high reg */ | ||
139 | +REG32(SPADDR4LO, 0xa0) /* Specific addr 4 low reg */ | ||
140 | +REG32(SPADDR4HI, 0xa4) /* Specific addr 4 high reg */ | ||
141 | +REG32(TIDMATCH1, 0xa8) /* Type ID1 Match reg */ | ||
142 | +REG32(TIDMATCH2, 0xac) /* Type ID2 Match reg */ | ||
143 | +REG32(TIDMATCH3, 0xb0) /* Type ID3 Match reg */ | ||
144 | +REG32(TIDMATCH4, 0xb4) /* Type ID4 Match reg */ | ||
145 | +REG32(WOLAN, 0xb8) /* Wake on LAN reg */ | ||
146 | +REG32(IPGSTRETCH, 0xbc) /* IPG Stretch reg */ | ||
147 | +REG32(SVLAN, 0xc0) /* Stacked VLAN reg */ | ||
148 | +REG32(MODID, 0xfc) /* Module ID reg */ | ||
149 | +REG32(OCTTXLO, 0x100) /* Octects transmitted Low reg */ | ||
150 | +REG32(OCTTXHI, 0x104) /* Octects transmitted High reg */ | ||
151 | +REG32(TXCNT, 0x108) /* Error-free Frames transmitted */ | ||
152 | +REG32(TXBCNT, 0x10c) /* Error-free Broadcast Frames */ | ||
153 | +REG32(TXMCNT, 0x110) /* Error-free Multicast Frame */ | ||
154 | +REG32(TXPAUSECNT, 0x114) /* Pause Frames Transmitted */ | ||
155 | +REG32(TX64CNT, 0x118) /* Error-free 64 TX */ | ||
156 | +REG32(TX65CNT, 0x11c) /* Error-free 65-127 TX */ | ||
157 | +REG32(TX128CNT, 0x120) /* Error-free 128-255 TX */ | ||
158 | +REG32(TX256CNT, 0x124) /* Error-free 256-511 */ | ||
159 | +REG32(TX512CNT, 0x128) /* Error-free 512-1023 TX */ | ||
160 | +REG32(TX1024CNT, 0x12c) /* Error-free 1024-1518 TX */ | ||
161 | +REG32(TX1519CNT, 0x130) /* Error-free larger than 1519 TX */ | ||
162 | +REG32(TXURUNCNT, 0x134) /* TX under run error counter */ | ||
163 | +REG32(SINGLECOLLCNT, 0x138) /* Single Collision Frames */ | ||
164 | +REG32(MULTCOLLCNT, 0x13c) /* Multiple Collision Frames */ | ||
165 | +REG32(EXCESSCOLLCNT, 0x140) /* Excessive Collision Frames */ | ||
166 | +REG32(LATECOLLCNT, 0x144) /* Late Collision Frames */ | ||
167 | +REG32(DEFERTXCNT, 0x148) /* Deferred Transmission Frames */ | ||
168 | +REG32(CSENSECNT, 0x14c) /* Carrier Sense Error Counter */ | ||
169 | +REG32(OCTRXLO, 0x150) /* Octects Received register Low */ | ||
170 | +REG32(OCTRXHI, 0x154) /* Octects Received register High */ | ||
171 | +REG32(RXCNT, 0x158) /* Error-free Frames Received */ | ||
172 | +REG32(RXBROADCNT, 0x15c) /* Error-free Broadcast Frames RX */ | ||
173 | +REG32(RXMULTICNT, 0x160) /* Error-free Multicast Frames RX */ | ||
174 | +REG32(RXPAUSECNT, 0x164) /* Pause Frames Received Counter */ | ||
175 | +REG32(RX64CNT, 0x168) /* Error-free 64 byte Frames RX */ | ||
176 | +REG32(RX65CNT, 0x16c) /* Error-free 65-127B Frames RX */ | ||
177 | +REG32(RX128CNT, 0x170) /* Error-free 128-255B Frames RX */ | ||
178 | +REG32(RX256CNT, 0x174) /* Error-free 256-512B Frames RX */ | ||
179 | +REG32(RX512CNT, 0x178) /* Error-free 512-1023B Frames RX */ | ||
180 | +REG32(RX1024CNT, 0x17c) /* Error-free 1024-1518B Frames RX */ | ||
181 | +REG32(RX1519CNT, 0x180) /* Error-free 1519-max Frames RX */ | ||
182 | +REG32(RXUNDERCNT, 0x184) /* Undersize Frames Received */ | ||
183 | +REG32(RXOVERCNT, 0x188) /* Oversize Frames Received */ | ||
184 | +REG32(RXJABCNT, 0x18c) /* Jabbers Received Counter */ | ||
185 | +REG32(RXFCSCNT, 0x190) /* Frame Check seq. Error Counter */ | ||
186 | +REG32(RXLENERRCNT, 0x194) /* Length Field Error Counter */ | ||
187 | +REG32(RXSYMERRCNT, 0x198) /* Symbol Error Counter */ | ||
188 | +REG32(RXALIGNERRCNT, 0x19c) /* Alignment Error Counter */ | ||
189 | +REG32(RXRSCERRCNT, 0x1a0) /* Receive Resource Error Counter */ | ||
190 | +REG32(RXORUNCNT, 0x1a4) /* Receive Overrun Counter */ | ||
191 | +REG32(RXIPCSERRCNT, 0x1a8) /* IP header Checksum Err Counter */ | ||
192 | +REG32(RXTCPCCNT, 0x1ac) /* TCP Checksum Error Counter */ | ||
193 | +REG32(RXUDPCCNT, 0x1b0) /* UDP Checksum Error Counter */ | ||
194 | |||
195 | -#define GEM_1588S (0x000001D0 / 4) /* 1588 Timer Seconds */ | ||
196 | -#define GEM_1588NS (0x000001D4 / 4) /* 1588 Timer Nanoseconds */ | ||
197 | -#define GEM_1588ADJ (0x000001D8 / 4) /* 1588 Timer Adjust */ | ||
198 | -#define GEM_1588INC (0x000001DC / 4) /* 1588 Timer Increment */ | ||
199 | -#define GEM_PTPETXS (0x000001E0 / 4) /* PTP Event Frame Transmitted (s) */ | ||
200 | -#define GEM_PTPETXNS (0x000001E4 / 4) /* | ||
201 | - * PTP Event Frame Transmitted (ns) | ||
202 | - */ | ||
203 | -#define GEM_PTPERXS (0x000001E8 / 4) /* PTP Event Frame Received (s) */ | ||
204 | -#define GEM_PTPERXNS (0x000001EC / 4) /* PTP Event Frame Received (ns) */ | ||
205 | -#define GEM_PTPPTXS (0x000001E0 / 4) /* PTP Peer Frame Transmitted (s) */ | ||
206 | -#define GEM_PTPPTXNS (0x000001E4 / 4) /* PTP Peer Frame Transmitted (ns) */ | ||
207 | -#define GEM_PTPPRXS (0x000001E8 / 4) /* PTP Peer Frame Received (s) */ | ||
208 | -#define GEM_PTPPRXNS (0x000001EC / 4) /* PTP Peer Frame Received (ns) */ | ||
209 | +REG32(1588S, 0x1d0) /* 1588 Timer Seconds */ | ||
210 | +REG32(1588NS, 0x1d4) /* 1588 Timer Nanoseconds */ | ||
211 | +REG32(1588ADJ, 0x1d8) /* 1588 Timer Adjust */ | ||
212 | +REG32(1588INC, 0x1dc) /* 1588 Timer Increment */ | ||
213 | +REG32(PTPETXS, 0x1e0) /* PTP Event Frame Transmitted (s) */ | ||
214 | +REG32(PTPETXNS, 0x1e4) /* PTP Event Frame Transmitted (ns) */ | ||
215 | +REG32(PTPERXS, 0x1e8) /* PTP Event Frame Received (s) */ | ||
216 | +REG32(PTPERXNS, 0x1ec) /* PTP Event Frame Received (ns) */ | ||
217 | +REG32(PTPPTXS, 0x1e0) /* PTP Peer Frame Transmitted (s) */ | ||
218 | +REG32(PTPPTXNS, 0x1e4) /* PTP Peer Frame Transmitted (ns) */ | ||
219 | +REG32(PTPPRXS, 0x1e8) /* PTP Peer Frame Received (s) */ | ||
220 | +REG32(PTPPRXNS, 0x1ec) /* PTP Peer Frame Received (ns) */ | ||
221 | |||
222 | /* Design Configuration Registers */ | ||
223 | -#define GEM_DESCONF (0x00000280 / 4) | ||
224 | -#define GEM_DESCONF2 (0x00000284 / 4) | ||
225 | -#define GEM_DESCONF3 (0x00000288 / 4) | ||
226 | -#define GEM_DESCONF4 (0x0000028C / 4) | ||
227 | -#define GEM_DESCONF5 (0x00000290 / 4) | ||
228 | -#define GEM_DESCONF6 (0x00000294 / 4) | ||
229 | +REG32(DESCONF, 0x280) | ||
230 | +REG32(DESCONF2, 0x284) | ||
231 | +REG32(DESCONF3, 0x288) | ||
232 | +REG32(DESCONF4, 0x28c) | ||
233 | +REG32(DESCONF5, 0x290) | ||
234 | +REG32(DESCONF6, 0x294) | ||
235 | #define GEM_DESCONF6_64B_MASK (1U << 23) | ||
236 | -#define GEM_DESCONF7 (0x00000298 / 4) | ||
237 | +REG32(DESCONF7, 0x298) | ||
238 | |||
239 | -#define GEM_INT_Q1_STATUS (0x00000400 / 4) | ||
240 | -#define GEM_INT_Q1_MASK (0x00000640 / 4) | ||
241 | +REG32(INT_Q1_STATUS, 0x400) | ||
242 | +REG32(INT_Q1_MASK, 0x640) | ||
243 | |||
244 | -#define GEM_TRANSMIT_Q1_PTR (0x00000440 / 4) | ||
245 | -#define GEM_TRANSMIT_Q7_PTR (GEM_TRANSMIT_Q1_PTR + 6) | ||
246 | +REG32(TRANSMIT_Q1_PTR, 0x440) | ||
247 | +REG32(TRANSMIT_Q7_PTR, 0x458) | ||
248 | |||
249 | -#define GEM_RECEIVE_Q1_PTR (0x00000480 / 4) | ||
250 | -#define GEM_RECEIVE_Q7_PTR (GEM_RECEIVE_Q1_PTR + 6) | ||
251 | +REG32(RECEIVE_Q1_PTR, 0x480) | ||
252 | +REG32(RECEIVE_Q7_PTR, 0x498) | ||
253 | |||
254 | -#define GEM_TBQPH (0x000004C8 / 4) | ||
255 | -#define GEM_RBQPH (0x000004D4 / 4) | ||
256 | +REG32(TBQPH, 0x4c8) | ||
257 | +REG32(RBQPH, 0x4d4) | ||
258 | |||
259 | -#define GEM_INT_Q1_ENABLE (0x00000600 / 4) | ||
260 | -#define GEM_INT_Q7_ENABLE (GEM_INT_Q1_ENABLE + 6) | ||
261 | +REG32(INT_Q1_ENABLE, 0x600) | ||
262 | +REG32(INT_Q7_ENABLE, 0x618) | ||
263 | |||
264 | -#define GEM_INT_Q1_DISABLE (0x00000620 / 4) | ||
265 | -#define GEM_INT_Q7_DISABLE (GEM_INT_Q1_DISABLE + 6) | ||
266 | +REG32(INT_Q1_DISABLE, 0x620) | ||
267 | +REG32(INT_Q7_DISABLE, 0x638) | ||
268 | |||
269 | -#define GEM_INT_Q1_MASK (0x00000640 / 4) | ||
270 | -#define GEM_INT_Q7_MASK (GEM_INT_Q1_MASK + 6) | ||
34 | - | 271 | - |
35 | struct MPS2SCC { | 272 | -#define GEM_SCREENING_TYPE1_REGISTER_0 (0x00000500 / 4) |
36 | /*< private >*/ | 273 | +REG32(SCREENING_TYPE1_REG0, 0x500) |
37 | SysBusDevice parent_obj; | 274 | |
38 | @@ -XXX,XX +XXX,XX @@ struct MPS2SCC { | 275 | #define GEM_ST1R_UDP_PORT_MATCH_ENABLE (1 << 29) |
39 | uint32_t dll; | 276 | #define GEM_ST1R_DSTC_ENABLE (1 << 28) |
40 | uint32_t aid; | 277 | @@ -XXX,XX +XXX,XX @@ |
41 | uint32_t id; | 278 | #define GEM_ST1R_QUEUE_SHIFT (0) |
42 | - uint32_t oscclk[NUM_OSCCLK]; | 279 | #define GEM_ST1R_QUEUE_WIDTH (3 - GEM_ST1R_QUEUE_SHIFT + 1) |
43 | - uint32_t oscclk_reset[NUM_OSCCLK]; | 280 | |
44 | + uint32_t num_oscclk; | 281 | -#define GEM_SCREENING_TYPE2_REGISTER_0 (0x00000540 / 4) |
45 | + uint32_t *oscclk; | 282 | +REG32(SCREENING_TYPE2_REG0, 0x540) |
46 | + uint32_t *oscclk_reset; | 283 | |
47 | }; | 284 | #define GEM_ST2R_COMPARE_A_ENABLE (1 << 18) |
48 | 285 | #define GEM_ST2R_COMPARE_A_SHIFT (13) | |
49 | #endif | 286 | @@ -XXX,XX +XXX,XX @@ |
50 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 287 | #define GEM_ST2R_QUEUE_SHIFT (0) |
51 | index XXXXXXX..XXXXXXX 100644 | 288 | #define GEM_ST2R_QUEUE_WIDTH (3 - GEM_ST2R_QUEUE_SHIFT + 1) |
52 | --- a/hw/arm/mps2-tz.c | 289 | |
53 | +++ b/hw/arm/mps2-tz.c | 290 | -#define GEM_SCREENING_TYPE2_ETHERTYPE_REG_0 (0x000006e0 / 4) |
54 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | 291 | -#define GEM_TYPE2_COMPARE_0_WORD_0 (0x00000700 / 4) |
55 | qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); | 292 | +REG32(SCREENING_TYPE2_ETHERTYPE_REG0, 0x6e0) |
56 | qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); | 293 | +REG32(TYPE2_COMPARE_0_WORD_0, 0x700) |
57 | qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | 294 | |
58 | + /* This will need to be per-FPGA image eventually */ | 295 | #define GEM_T2CW1_COMPARE_OFFSET_SHIFT (7) |
59 | + qdev_prop_set_uint32(sccdev, "len-oscclk", 3); | 296 | #define GEM_T2CW1_COMPARE_OFFSET_WIDTH (8 - GEM_T2CW1_COMPARE_OFFSET_SHIFT + 1) |
60 | + qdev_prop_set_uint32(sccdev, "oscclk[0]", 50000000); | 297 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t tx_desc_get_buffer(CadenceGEMState *s, uint32_t *desc) |
61 | + qdev_prop_set_uint32(sccdev, "oscclk[1]", 24576000); | 298 | { |
62 | + qdev_prop_set_uint32(sccdev, "oscclk[2]", 25000000); | 299 | uint64_t ret = desc[0]; |
63 | sysbus_realize(SYS_BUS_DEVICE(scc), &error_fatal); | 300 | |
64 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(sccdev), 0); | 301 | - if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { |
302 | + if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
303 | ret |= (uint64_t)desc[2] << 32; | ||
304 | } | ||
305 | return ret; | ||
306 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t rx_desc_get_buffer(CadenceGEMState *s, uint32_t *desc) | ||
307 | { | ||
308 | uint64_t ret = desc[0] & ~0x3UL; | ||
309 | |||
310 | - if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
311 | + if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
312 | ret |= (uint64_t)desc[2] << 32; | ||
313 | } | ||
314 | return ret; | ||
315 | @@ -XXX,XX +XXX,XX @@ static inline int gem_get_desc_len(CadenceGEMState *s, bool rx_n_tx) | ||
316 | { | ||
317 | int ret = 2; | ||
318 | |||
319 | - if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
320 | + if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
321 | ret += 2; | ||
322 | } | ||
323 | - if (s->regs[GEM_DMACFG] & (rx_n_tx ? GEM_DMACFG_RX_BD_EXT | ||
324 | + if (s->regs[R_DMACFG] & (rx_n_tx ? GEM_DMACFG_RX_BD_EXT | ||
325 | : GEM_DMACFG_TX_BD_EXT)) { | ||
326 | ret += 2; | ||
327 | } | ||
328 | @@ -XXX,XX +XXX,XX @@ static const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
329 | static uint32_t gem_get_max_buf_len(CadenceGEMState *s, bool tx) | ||
330 | { | ||
331 | uint32_t size; | ||
332 | - if (s->regs[GEM_NWCFG] & GEM_NWCFG_JUMBO_FRAME) { | ||
333 | - size = s->regs[GEM_JUMBO_MAX_LEN]; | ||
334 | + if (s->regs[R_NWCFG] & GEM_NWCFG_JUMBO_FRAME) { | ||
335 | + size = s->regs[R_JUMBO_MAX_LEN]; | ||
336 | if (size > s->jumbo_max_len) { | ||
337 | size = s->jumbo_max_len; | ||
338 | qemu_log_mask(LOG_GUEST_ERROR, "GEM_JUMBO_MAX_LEN reg cannot be" | ||
339 | @@ -XXX,XX +XXX,XX @@ static uint32_t gem_get_max_buf_len(CadenceGEMState *s, bool tx) | ||
340 | } else if (tx) { | ||
341 | size = 1518; | ||
342 | } else { | ||
343 | - size = s->regs[GEM_NWCFG] & GEM_NWCFG_RCV_1538 ? 1538 : 1518; | ||
344 | + size = s->regs[R_NWCFG] & GEM_NWCFG_RCV_1538 ? 1538 : 1518; | ||
345 | } | ||
346 | return size; | ||
65 | } | 347 | } |
66 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | 348 | @@ -XXX,XX +XXX,XX @@ static uint32_t gem_get_max_buf_len(CadenceGEMState *s, bool tx) |
67 | index XXXXXXX..XXXXXXX 100644 | 349 | static void gem_set_isr(CadenceGEMState *s, int q, uint32_t flag) |
68 | --- a/hw/arm/mps2.c | ||
69 | +++ b/hw/arm/mps2.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
71 | qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); | ||
72 | qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); | ||
73 | qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | ||
74 | + /* All these FPGA images have the same OSCCLK configuration */ | ||
75 | + qdev_prop_set_uint32(sccdev, "len-oscclk", 3); | ||
76 | + qdev_prop_set_uint32(sccdev, "oscclk[0]", 50000000); | ||
77 | + qdev_prop_set_uint32(sccdev, "oscclk[1]", 24576000); | ||
78 | + qdev_prop_set_uint32(sccdev, "oscclk[2]", 25000000); | ||
79 | sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal); | ||
80 | sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000); | ||
81 | object_initialize_child(OBJECT(mms), "fpgaio", | ||
82 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/hw/misc/mps2-scc.c | ||
85 | +++ b/hw/misc/mps2-scc.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static bool scc_cfg_write(MPS2SCC *s, unsigned function, | ||
87 | { | 350 | { |
88 | trace_mps2_scc_cfg_write(function, device, value); | 351 | if (q == 0) { |
89 | 352 | - s->regs[GEM_ISR] |= flag & ~(s->regs[GEM_IMR]); | |
90 | - if (function != 1 || device >= NUM_OSCCLK) { | 353 | + s->regs[R_ISR] |= flag & ~(s->regs[R_IMR]); |
91 | + if (function != 1 || device >= s->num_oscclk) { | 354 | } else { |
92 | qemu_log_mask(LOG_GUEST_ERROR, | 355 | - s->regs[GEM_INT_Q1_STATUS + q - 1] |= flag & |
93 | "MPS2 SCC config write: bad function %d device %d\n", | 356 | - ~(s->regs[GEM_INT_Q1_MASK + q - 1]); |
94 | function, device); | 357 | + s->regs[R_INT_Q1_STATUS + q - 1] |= flag & |
95 | @@ -XXX,XX +XXX,XX @@ static bool scc_cfg_write(MPS2SCC *s, unsigned function, | 358 | + ~(s->regs[R_INT_Q1_MASK + q - 1]); |
96 | static bool scc_cfg_read(MPS2SCC *s, unsigned function, | 359 | } |
97 | unsigned device, uint32_t *value) | 360 | } |
361 | |||
362 | @@ -XXX,XX +XXX,XX @@ static void gem_init_register_masks(CadenceGEMState *s) | ||
363 | unsigned int i; | ||
364 | /* Mask of register bits which are read only */ | ||
365 | memset(&s->regs_ro[0], 0, sizeof(s->regs_ro)); | ||
366 | - s->regs_ro[GEM_NWCTRL] = 0xFFF80000; | ||
367 | - s->regs_ro[GEM_NWSTATUS] = 0xFFFFFFFF; | ||
368 | - s->regs_ro[GEM_DMACFG] = 0x8E00F000; | ||
369 | - s->regs_ro[GEM_TXSTATUS] = 0xFFFFFE08; | ||
370 | - s->regs_ro[GEM_RXQBASE] = 0x00000003; | ||
371 | - s->regs_ro[GEM_TXQBASE] = 0x00000003; | ||
372 | - s->regs_ro[GEM_RXSTATUS] = 0xFFFFFFF0; | ||
373 | - s->regs_ro[GEM_ISR] = 0xFFFFFFFF; | ||
374 | - s->regs_ro[GEM_IMR] = 0xFFFFFFFF; | ||
375 | - s->regs_ro[GEM_MODID] = 0xFFFFFFFF; | ||
376 | + s->regs_ro[R_NWCTRL] = 0xFFF80000; | ||
377 | + s->regs_ro[R_NWSTATUS] = 0xFFFFFFFF; | ||
378 | + s->regs_ro[R_DMACFG] = 0x8E00F000; | ||
379 | + s->regs_ro[R_TXSTATUS] = 0xFFFFFE08; | ||
380 | + s->regs_ro[R_RXQBASE] = 0x00000003; | ||
381 | + s->regs_ro[R_TXQBASE] = 0x00000003; | ||
382 | + s->regs_ro[R_RXSTATUS] = 0xFFFFFFF0; | ||
383 | + s->regs_ro[R_ISR] = 0xFFFFFFFF; | ||
384 | + s->regs_ro[R_IMR] = 0xFFFFFFFF; | ||
385 | + s->regs_ro[R_MODID] = 0xFFFFFFFF; | ||
386 | for (i = 0; i < s->num_priority_queues; i++) { | ||
387 | - s->regs_ro[GEM_INT_Q1_STATUS + i] = 0xFFFFFFFF; | ||
388 | - s->regs_ro[GEM_INT_Q1_ENABLE + i] = 0xFFFFF319; | ||
389 | - s->regs_ro[GEM_INT_Q1_DISABLE + i] = 0xFFFFF319; | ||
390 | - s->regs_ro[GEM_INT_Q1_MASK + i] = 0xFFFFFFFF; | ||
391 | + s->regs_ro[R_INT_Q1_STATUS + i] = 0xFFFFFFFF; | ||
392 | + s->regs_ro[R_INT_Q1_ENABLE + i] = 0xFFFFF319; | ||
393 | + s->regs_ro[R_INT_Q1_DISABLE + i] = 0xFFFFF319; | ||
394 | + s->regs_ro[R_INT_Q1_MASK + i] = 0xFFFFFFFF; | ||
395 | } | ||
396 | |||
397 | /* Mask of register bits which are clear on read */ | ||
398 | memset(&s->regs_rtc[0], 0, sizeof(s->regs_rtc)); | ||
399 | - s->regs_rtc[GEM_ISR] = 0xFFFFFFFF; | ||
400 | + s->regs_rtc[R_ISR] = 0xFFFFFFFF; | ||
401 | for (i = 0; i < s->num_priority_queues; i++) { | ||
402 | - s->regs_rtc[GEM_INT_Q1_STATUS + i] = 0x00000CE6; | ||
403 | + s->regs_rtc[R_INT_Q1_STATUS + i] = 0x00000CE6; | ||
404 | } | ||
405 | |||
406 | /* Mask of register bits which are write 1 to clear */ | ||
407 | memset(&s->regs_w1c[0], 0, sizeof(s->regs_w1c)); | ||
408 | - s->regs_w1c[GEM_TXSTATUS] = 0x000001F7; | ||
409 | - s->regs_w1c[GEM_RXSTATUS] = 0x0000000F; | ||
410 | + s->regs_w1c[R_TXSTATUS] = 0x000001F7; | ||
411 | + s->regs_w1c[R_RXSTATUS] = 0x0000000F; | ||
412 | |||
413 | /* Mask of register bits which are write only */ | ||
414 | memset(&s->regs_wo[0], 0, sizeof(s->regs_wo)); | ||
415 | - s->regs_wo[GEM_NWCTRL] = 0x00073E60; | ||
416 | - s->regs_wo[GEM_IER] = 0x07FFFFFF; | ||
417 | - s->regs_wo[GEM_IDR] = 0x07FFFFFF; | ||
418 | + s->regs_wo[R_NWCTRL] = 0x00073E60; | ||
419 | + s->regs_wo[R_IER] = 0x07FFFFFF; | ||
420 | + s->regs_wo[R_IDR] = 0x07FFFFFF; | ||
421 | for (i = 0; i < s->num_priority_queues; i++) { | ||
422 | - s->regs_wo[GEM_INT_Q1_ENABLE + i] = 0x00000CE6; | ||
423 | - s->regs_wo[GEM_INT_Q1_DISABLE + i] = 0x00000CE6; | ||
424 | + s->regs_wo[R_INT_Q1_ENABLE + i] = 0x00000CE6; | ||
425 | + s->regs_wo[R_INT_Q1_DISABLE + i] = 0x00000CE6; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | @@ -XXX,XX +XXX,XX @@ static bool gem_can_receive(NetClientState *nc) | ||
430 | s = qemu_get_nic_opaque(nc); | ||
431 | |||
432 | /* Do nothing if receive is not enabled. */ | ||
433 | - if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_RXENA)) { | ||
434 | + if (!(s->regs[R_NWCTRL] & GEM_NWCTRL_RXENA)) { | ||
435 | if (s->can_rx_state != 1) { | ||
436 | s->can_rx_state = 1; | ||
437 | DB_PRINT("can't receive - no enable\n"); | ||
438 | @@ -XXX,XX +XXX,XX @@ static void gem_update_int_status(CadenceGEMState *s) | ||
98 | { | 439 | { |
99 | - if (function != 1 || device >= NUM_OSCCLK) { | 440 | int i; |
100 | + if (function != 1 || device >= s->num_oscclk) { | 441 | |
101 | qemu_log_mask(LOG_GUEST_ERROR, | 442 | - qemu_set_irq(s->irq[0], !!s->regs[GEM_ISR]); |
102 | "MPS2 SCC config read: bad function %d device %d\n", | 443 | + qemu_set_irq(s->irq[0], !!s->regs[R_ISR]); |
103 | function, device); | 444 | |
104 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_reset(DeviceState *dev) | 445 | for (i = 1; i < s->num_priority_queues; ++i) { |
105 | s->cfgctrl = 0x100000; | 446 | - qemu_set_irq(s->irq[i], !!s->regs[GEM_INT_Q1_STATUS + i - 1]); |
106 | s->cfgstat = 0; | 447 | + qemu_set_irq(s->irq[i], !!s->regs[R_INT_Q1_STATUS + i - 1]); |
107 | s->dll = 0xffff0001; | 448 | } |
108 | - for (i = 0; i < NUM_OSCCLK; i++) { | ||
109 | + for (i = 0; i < s->num_oscclk; i++) { | ||
110 | s->oscclk[i] = s->oscclk_reset[i]; | ||
111 | } | ||
112 | for (i = 0; i < ARRAY_SIZE(s->led); i++) { | ||
113 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_realize(DeviceState *dev, Error **errp) | ||
114 | LED_COLOR_GREEN, name); | ||
115 | g_free(name); | ||
116 | } | ||
117 | + | ||
118 | + s->oscclk = g_new0(uint32_t, s->num_oscclk); | ||
119 | } | 449 | } |
120 | 450 | ||
121 | static const VMStateDescription mps2_scc_vmstate = { | 451 | @@ -XXX,XX +XXX,XX @@ static void gem_receive_updatestats(CadenceGEMState *s, const uint8_t *packet, |
122 | .name = "mps2-scc", | 452 | uint64_t octets; |
123 | - .version_id = 1, | 453 | |
124 | - .minimum_version_id = 1, | 454 | /* Total octets (bytes) received */ |
125 | + .version_id = 2, | 455 | - octets = ((uint64_t)(s->regs[GEM_OCTRXLO]) << 32) | |
126 | + .minimum_version_id = 2, | 456 | - s->regs[GEM_OCTRXHI]; |
127 | .fields = (VMStateField[]) { | 457 | + octets = ((uint64_t)(s->regs[R_OCTRXLO]) << 32) | |
128 | VMSTATE_UINT32(cfg0, MPS2SCC), | 458 | + s->regs[R_OCTRXHI]; |
129 | VMSTATE_UINT32(cfg1, MPS2SCC), | 459 | octets += bytes; |
130 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription mps2_scc_vmstate = { | 460 | - s->regs[GEM_OCTRXLO] = octets >> 32; |
131 | VMSTATE_UINT32(cfgctrl, MPS2SCC), | 461 | - s->regs[GEM_OCTRXHI] = octets; |
132 | VMSTATE_UINT32(cfgstat, MPS2SCC), | 462 | + s->regs[R_OCTRXLO] = octets >> 32; |
133 | VMSTATE_UINT32(dll, MPS2SCC), | 463 | + s->regs[R_OCTRXHI] = octets; |
134 | - VMSTATE_UINT32_ARRAY(oscclk, MPS2SCC, NUM_OSCCLK), | 464 | |
135 | + VMSTATE_VARRAY_UINT32(oscclk, MPS2SCC, num_oscclk, | 465 | /* Error-free Frames received */ |
136 | + 0, vmstate_info_uint32, uint32_t), | 466 | - s->regs[GEM_RXCNT]++; |
137 | VMSTATE_END_OF_LIST() | 467 | + s->regs[R_RXCNT]++; |
138 | } | 468 | |
139 | }; | 469 | /* Error-free Broadcast Frames counter */ |
140 | @@ -XXX,XX +XXX,XX @@ static Property mps2_scc_properties[] = { | 470 | if (!memcmp(packet, broadcast_addr, 6)) { |
141 | DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, cfg4, 0), | 471 | - s->regs[GEM_RXBROADCNT]++; |
142 | DEFINE_PROP_UINT32("scc-aid", MPS2SCC, aid, 0), | 472 | + s->regs[R_RXBROADCNT]++; |
143 | DEFINE_PROP_UINT32("scc-id", MPS2SCC, id, 0), | 473 | } |
144 | - /* These are the initial settings for the source clocks on the board. | 474 | |
145 | + /* | 475 | /* Error-free Multicast Frames counter */ |
146 | + * These are the initial settings for the source clocks on the board. | 476 | if (packet[0] == 0x01) { |
147 | * In hardware they can be configured via a config file read by the | 477 | - s->regs[GEM_RXMULTICNT]++; |
148 | * motherboard configuration controller to suit the FPGA image. | 478 | + s->regs[R_RXMULTICNT]++; |
149 | - * These default values are used by most of the standard FPGA images. | 479 | } |
480 | |||
481 | if (bytes <= 64) { | ||
482 | - s->regs[GEM_RX64CNT]++; | ||
483 | + s->regs[R_RX64CNT]++; | ||
484 | } else if (bytes <= 127) { | ||
485 | - s->regs[GEM_RX65CNT]++; | ||
486 | + s->regs[R_RX65CNT]++; | ||
487 | } else if (bytes <= 255) { | ||
488 | - s->regs[GEM_RX128CNT]++; | ||
489 | + s->regs[R_RX128CNT]++; | ||
490 | } else if (bytes <= 511) { | ||
491 | - s->regs[GEM_RX256CNT]++; | ||
492 | + s->regs[R_RX256CNT]++; | ||
493 | } else if (bytes <= 1023) { | ||
494 | - s->regs[GEM_RX512CNT]++; | ||
495 | + s->regs[R_RX512CNT]++; | ||
496 | } else if (bytes <= 1518) { | ||
497 | - s->regs[GEM_RX1024CNT]++; | ||
498 | + s->regs[R_RX1024CNT]++; | ||
499 | } else { | ||
500 | - s->regs[GEM_RX1519CNT]++; | ||
501 | + s->regs[R_RX1519CNT]++; | ||
502 | } | ||
503 | } | ||
504 | |||
505 | @@ -XXX,XX +XXX,XX @@ static int gem_mac_address_filter(CadenceGEMState *s, const uint8_t *packet) | ||
506 | int i, is_mc; | ||
507 | |||
508 | /* Promiscuous mode? */ | ||
509 | - if (s->regs[GEM_NWCFG] & GEM_NWCFG_PROMISC) { | ||
510 | + if (s->regs[R_NWCFG] & GEM_NWCFG_PROMISC) { | ||
511 | return GEM_RX_PROMISCUOUS_ACCEPT; | ||
512 | } | ||
513 | |||
514 | if (!memcmp(packet, broadcast_addr, 6)) { | ||
515 | /* Reject broadcast packets? */ | ||
516 | - if (s->regs[GEM_NWCFG] & GEM_NWCFG_BCAST_REJ) { | ||
517 | + if (s->regs[R_NWCFG] & GEM_NWCFG_BCAST_REJ) { | ||
518 | return GEM_RX_REJECT; | ||
519 | } | ||
520 | return GEM_RX_BROADCAST_ACCEPT; | ||
521 | @@ -XXX,XX +XXX,XX @@ static int gem_mac_address_filter(CadenceGEMState *s, const uint8_t *packet) | ||
522 | |||
523 | /* Accept packets -w- hash match? */ | ||
524 | is_mc = is_multicast_ether_addr(packet); | ||
525 | - if ((is_mc && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HASH)) || | ||
526 | - (!is_mc && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HASH))) { | ||
527 | + if ((is_mc && (s->regs[R_NWCFG] & GEM_NWCFG_MCAST_HASH)) || | ||
528 | + (!is_mc && (s->regs[R_NWCFG] & GEM_NWCFG_UCAST_HASH))) { | ||
529 | uint64_t buckets; | ||
530 | unsigned hash_index; | ||
531 | |||
532 | hash_index = calc_mac_hash(packet); | ||
533 | - buckets = ((uint64_t)s->regs[GEM_HASHHI] << 32) | s->regs[GEM_HASHLO]; | ||
534 | + buckets = ((uint64_t)s->regs[R_HASHHI] << 32) | s->regs[R_HASHLO]; | ||
535 | if ((buckets >> hash_index) & 1) { | ||
536 | return is_mc ? GEM_RX_MULTICAST_HASH_ACCEPT | ||
537 | : GEM_RX_UNICAST_HASH_ACCEPT; | ||
538 | @@ -XXX,XX +XXX,XX @@ static int gem_mac_address_filter(CadenceGEMState *s, const uint8_t *packet) | ||
539 | } | ||
540 | |||
541 | /* Check all 4 specific addresses */ | ||
542 | - gem_spaddr = (uint8_t *)&(s->regs[GEM_SPADDR1LO]); | ||
543 | + gem_spaddr = (uint8_t *)&(s->regs[R_SPADDR1LO]); | ||
544 | for (i = 3; i >= 0; i--) { | ||
545 | if (s->sar_active[i] && !memcmp(packet, gem_spaddr + 8 * i, 6)) { | ||
546 | return GEM_RX_SAR_ACCEPT + i; | ||
547 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
548 | int i, j; | ||
549 | |||
550 | for (i = 0; i < s->num_type1_screeners; i++) { | ||
551 | - reg = s->regs[GEM_SCREENING_TYPE1_REGISTER_0 + i]; | ||
552 | + reg = s->regs[R_SCREENING_TYPE1_REG0 + i]; | ||
553 | matched = false; | ||
554 | mismatched = false; | ||
555 | |||
556 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
557 | } | ||
558 | |||
559 | for (i = 0; i < s->num_type2_screeners; i++) { | ||
560 | - reg = s->regs[GEM_SCREENING_TYPE2_REGISTER_0 + i]; | ||
561 | + reg = s->regs[R_SCREENING_TYPE2_REG0 + i]; | ||
562 | matched = false; | ||
563 | mismatched = false; | ||
564 | |||
565 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
566 | qemu_log_mask(LOG_GUEST_ERROR, "Out of range ethertype " | ||
567 | "register index: %d\n", et_idx); | ||
568 | } | ||
569 | - if (type == s->regs[GEM_SCREENING_TYPE2_ETHERTYPE_REG_0 + | ||
570 | + if (type == s->regs[R_SCREENING_TYPE2_ETHERTYPE_REG0 + | ||
571 | et_idx]) { | ||
572 | matched = true; | ||
573 | } else { | ||
574 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
575 | "register index: %d\n", cr_idx); | ||
576 | } | ||
577 | |||
578 | - cr0 = s->regs[GEM_TYPE2_COMPARE_0_WORD_0 + cr_idx * 2]; | ||
579 | - cr1 = s->regs[GEM_TYPE2_COMPARE_0_WORD_0 + cr_idx * 2 + 1]; | ||
580 | + cr0 = s->regs[R_TYPE2_COMPARE_0_WORD_0 + cr_idx * 2]; | ||
581 | + cr1 = s->regs[R_TYPE2_COMPARE_0_WORD_0 + cr_idx * 2 + 1]; | ||
582 | offset = extract32(cr1, GEM_T2CW1_OFFSET_VALUE_SHIFT, | ||
583 | GEM_T2CW1_OFFSET_VALUE_WIDTH); | ||
584 | |||
585 | @@ -XXX,XX +XXX,XX @@ static uint32_t gem_get_queue_base_addr(CadenceGEMState *s, bool tx, int q) | ||
586 | |||
587 | switch (q) { | ||
588 | case 0: | ||
589 | - base_addr = s->regs[tx ? GEM_TXQBASE : GEM_RXQBASE]; | ||
590 | + base_addr = s->regs[tx ? R_TXQBASE : R_RXQBASE]; | ||
591 | break; | ||
592 | case 1 ... (MAX_PRIORITY_QUEUES - 1): | ||
593 | - base_addr = s->regs[(tx ? GEM_TRANSMIT_Q1_PTR : | ||
594 | - GEM_RECEIVE_Q1_PTR) + q - 1]; | ||
595 | + base_addr = s->regs[(tx ? R_TRANSMIT_Q1_PTR : | ||
596 | + R_RECEIVE_Q1_PTR) + q - 1]; | ||
597 | break; | ||
598 | default: | ||
599 | g_assert_not_reached(); | ||
600 | @@ -XXX,XX +XXX,XX @@ static hwaddr gem_get_desc_addr(CadenceGEMState *s, bool tx, int q) | ||
601 | { | ||
602 | hwaddr desc_addr = 0; | ||
603 | |||
604 | - if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
605 | - desc_addr = s->regs[tx ? GEM_TBQPH : GEM_RBQPH]; | ||
606 | + if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
607 | + desc_addr = s->regs[tx ? R_TBQPH : R_RBQPH]; | ||
608 | } | ||
609 | desc_addr <<= 32; | ||
610 | desc_addr |= tx ? s->tx_desc_addr[q] : s->rx_desc_addr[q]; | ||
611 | @@ -XXX,XX +XXX,XX @@ static void gem_get_rx_desc(CadenceGEMState *s, int q) | ||
612 | /* Descriptor owned by software ? */ | ||
613 | if (rx_desc_get_ownership(s->rx_desc[q]) == 1) { | ||
614 | DB_PRINT("descriptor 0x%" HWADDR_PRIx " owned by sw.\n", desc_addr); | ||
615 | - s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; | ||
616 | + s->regs[R_RXSTATUS] |= GEM_RXSTATUS_NOBUF; | ||
617 | gem_set_isr(s, q, GEM_INT_RXUSED); | ||
618 | /* Handle interrupt consequences */ | ||
619 | gem_update_int_status(s); | ||
620 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
621 | } | ||
622 | |||
623 | /* Discard packets with receive length error enabled ? */ | ||
624 | - if (s->regs[GEM_NWCFG] & GEM_NWCFG_LERR_DISC) { | ||
625 | + if (s->regs[R_NWCFG] & GEM_NWCFG_LERR_DISC) { | ||
626 | unsigned type_len; | ||
627 | |||
628 | /* Fish the ethertype / length field out of the RX packet */ | ||
629 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
630 | /* | ||
631 | * Determine configured receive buffer offset (probably 0) | ||
150 | */ | 632 | */ |
151 | - DEFINE_PROP_UINT32("oscclk0", MPS2SCC, oscclk_reset[0], 50000000), | 633 | - rxbuf_offset = (s->regs[GEM_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >> |
152 | - DEFINE_PROP_UINT32("oscclk1", MPS2SCC, oscclk_reset[1], 24576000), | 634 | + rxbuf_offset = (s->regs[R_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >> |
153 | - DEFINE_PROP_UINT32("oscclk2", MPS2SCC, oscclk_reset[2], 25000000), | 635 | GEM_NWCFG_BUFF_OFST_S; |
154 | + DEFINE_PROP_ARRAY("oscclk", MPS2SCC, num_oscclk, oscclk_reset, | 636 | |
155 | + qdev_prop_uint32, uint32_t), | 637 | /* The configure size of each receive buffer. Determines how many |
156 | DEFINE_PROP_END_OF_LIST(), | 638 | * buffers needed to hold this packet. |
157 | }; | 639 | */ |
640 | - rxbufsize = ((s->regs[GEM_DMACFG] & GEM_DMACFG_RBUFSZ_M) >> | ||
641 | + rxbufsize = ((s->regs[R_DMACFG] & GEM_DMACFG_RBUFSZ_M) >> | ||
642 | GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL; | ||
643 | bytes_to_copy = size; | ||
644 | |||
645 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
646 | } | ||
647 | |||
648 | /* Strip of FCS field ? (usually yes) */ | ||
649 | - if (s->regs[GEM_NWCFG] & GEM_NWCFG_STRIP_FCS) { | ||
650 | + if (s->regs[R_NWCFG] & GEM_NWCFG_STRIP_FCS) { | ||
651 | rxbuf_ptr = (void *)buf; | ||
652 | } else { | ||
653 | unsigned crc_val; | ||
654 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
655 | /* Count it */ | ||
656 | gem_receive_updatestats(s, buf, size); | ||
657 | |||
658 | - s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; | ||
659 | + s->regs[R_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; | ||
660 | gem_set_isr(s, q, GEM_INT_RXCMPL); | ||
661 | |||
662 | /* Handle interrupt consequences */ | ||
663 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit_updatestats(CadenceGEMState *s, const uint8_t *packet, | ||
664 | uint64_t octets; | ||
665 | |||
666 | /* Total octets (bytes) transmitted */ | ||
667 | - octets = ((uint64_t)(s->regs[GEM_OCTTXLO]) << 32) | | ||
668 | - s->regs[GEM_OCTTXHI]; | ||
669 | + octets = ((uint64_t)(s->regs[R_OCTTXLO]) << 32) | | ||
670 | + s->regs[R_OCTTXHI]; | ||
671 | octets += bytes; | ||
672 | - s->regs[GEM_OCTTXLO] = octets >> 32; | ||
673 | - s->regs[GEM_OCTTXHI] = octets; | ||
674 | + s->regs[R_OCTTXLO] = octets >> 32; | ||
675 | + s->regs[R_OCTTXHI] = octets; | ||
676 | |||
677 | /* Error-free Frames transmitted */ | ||
678 | - s->regs[GEM_TXCNT]++; | ||
679 | + s->regs[R_TXCNT]++; | ||
680 | |||
681 | /* Error-free Broadcast Frames counter */ | ||
682 | if (!memcmp(packet, broadcast_addr, 6)) { | ||
683 | - s->regs[GEM_TXBCNT]++; | ||
684 | + s->regs[R_TXBCNT]++; | ||
685 | } | ||
686 | |||
687 | /* Error-free Multicast Frames counter */ | ||
688 | if (packet[0] == 0x01) { | ||
689 | - s->regs[GEM_TXMCNT]++; | ||
690 | + s->regs[R_TXMCNT]++; | ||
691 | } | ||
692 | |||
693 | if (bytes <= 64) { | ||
694 | - s->regs[GEM_TX64CNT]++; | ||
695 | + s->regs[R_TX64CNT]++; | ||
696 | } else if (bytes <= 127) { | ||
697 | - s->regs[GEM_TX65CNT]++; | ||
698 | + s->regs[R_TX65CNT]++; | ||
699 | } else if (bytes <= 255) { | ||
700 | - s->regs[GEM_TX128CNT]++; | ||
701 | + s->regs[R_TX128CNT]++; | ||
702 | } else if (bytes <= 511) { | ||
703 | - s->regs[GEM_TX256CNT]++; | ||
704 | + s->regs[R_TX256CNT]++; | ||
705 | } else if (bytes <= 1023) { | ||
706 | - s->regs[GEM_TX512CNT]++; | ||
707 | + s->regs[R_TX512CNT]++; | ||
708 | } else if (bytes <= 1518) { | ||
709 | - s->regs[GEM_TX1024CNT]++; | ||
710 | + s->regs[R_TX1024CNT]++; | ||
711 | } else { | ||
712 | - s->regs[GEM_TX1519CNT]++; | ||
713 | + s->regs[R_TX1519CNT]++; | ||
714 | } | ||
715 | } | ||
716 | |||
717 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
718 | int q = 0; | ||
719 | |||
720 | /* Do nothing if transmit is not enabled. */ | ||
721 | - if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) { | ||
722 | + if (!(s->regs[R_NWCTRL] & GEM_NWCTRL_TXENA)) { | ||
723 | return; | ||
724 | } | ||
725 | |||
726 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
727 | while (tx_desc_get_used(desc) == 0) { | ||
728 | |||
729 | /* Do nothing if transmit is not enabled. */ | ||
730 | - if (!(s->regs[GEM_NWCTRL] & GEM_NWCTRL_TXENA)) { | ||
731 | + if (!(s->regs[R_NWCTRL] & GEM_NWCTRL_TXENA)) { | ||
732 | return; | ||
733 | } | ||
734 | print_gem_tx_desc(desc, q); | ||
735 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
736 | } | ||
737 | DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr[q]); | ||
738 | |||
739 | - s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_TXCMPL; | ||
740 | + s->regs[R_TXSTATUS] |= GEM_TXSTATUS_TXCMPL; | ||
741 | gem_set_isr(s, q, GEM_INT_TXCMPL); | ||
742 | |||
743 | /* Handle interrupt consequences */ | ||
744 | gem_update_int_status(s); | ||
745 | |||
746 | /* Is checksum offload enabled? */ | ||
747 | - if (s->regs[GEM_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) { | ||
748 | + if (s->regs[R_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) { | ||
749 | net_checksum_calculate(s->tx_packet, total_bytes, CSUM_ALL); | ||
750 | } | ||
751 | |||
752 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
753 | gem_transmit_updatestats(s, s->tx_packet, total_bytes); | ||
754 | |||
755 | /* Send the packet somewhere */ | ||
756 | - if (s->phy_loop || (s->regs[GEM_NWCTRL] & | ||
757 | + if (s->phy_loop || (s->regs[R_NWCTRL] & | ||
758 | GEM_NWCTRL_LOCALLOOP)) { | ||
759 | qemu_receive_packet(qemu_get_queue(s->nic), s->tx_packet, | ||
760 | total_bytes); | ||
761 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
762 | |||
763 | /* read next descriptor */ | ||
764 | if (tx_desc_get_wrap(desc)) { | ||
765 | - | ||
766 | - if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
767 | - packet_desc_addr = s->regs[GEM_TBQPH]; | ||
768 | + if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
769 | + packet_desc_addr = s->regs[R_TBQPH]; | ||
770 | packet_desc_addr <<= 32; | ||
771 | } else { | ||
772 | packet_desc_addr = 0; | ||
773 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
774 | } | ||
775 | |||
776 | if (tx_desc_get_used(desc)) { | ||
777 | - s->regs[GEM_TXSTATUS] |= GEM_TXSTATUS_USED; | ||
778 | + s->regs[R_TXSTATUS] |= GEM_TXSTATUS_USED; | ||
779 | /* IRQ TXUSED is defined only for queue 0 */ | ||
780 | if (q == 0) { | ||
781 | gem_set_isr(s, 0, GEM_INT_TXUSED); | ||
782 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | ||
783 | |||
784 | /* Set post reset register values */ | ||
785 | memset(&s->regs[0], 0, sizeof(s->regs)); | ||
786 | - s->regs[GEM_NWCFG] = 0x00080000; | ||
787 | - s->regs[GEM_NWSTATUS] = 0x00000006; | ||
788 | - s->regs[GEM_DMACFG] = 0x00020784; | ||
789 | - s->regs[GEM_IMR] = 0x07ffffff; | ||
790 | - s->regs[GEM_TXPAUSE] = 0x0000ffff; | ||
791 | - s->regs[GEM_TXPARTIALSF] = 0x000003ff; | ||
792 | - s->regs[GEM_RXPARTIALSF] = 0x000003ff; | ||
793 | - s->regs[GEM_MODID] = s->revision; | ||
794 | - s->regs[GEM_DESCONF] = 0x02D00111; | ||
795 | - s->regs[GEM_DESCONF2] = 0x2ab10000 | s->jumbo_max_len; | ||
796 | - s->regs[GEM_DESCONF5] = 0x002f2045; | ||
797 | - s->regs[GEM_DESCONF6] = GEM_DESCONF6_64B_MASK; | ||
798 | - s->regs[GEM_INT_Q1_MASK] = 0x00000CE6; | ||
799 | - s->regs[GEM_JUMBO_MAX_LEN] = s->jumbo_max_len; | ||
800 | + s->regs[R_NWCFG] = 0x00080000; | ||
801 | + s->regs[R_NWSTATUS] = 0x00000006; | ||
802 | + s->regs[R_DMACFG] = 0x00020784; | ||
803 | + s->regs[R_IMR] = 0x07ffffff; | ||
804 | + s->regs[R_TXPAUSE] = 0x0000ffff; | ||
805 | + s->regs[R_TXPARTIALSF] = 0x000003ff; | ||
806 | + s->regs[R_RXPARTIALSF] = 0x000003ff; | ||
807 | + s->regs[R_MODID] = s->revision; | ||
808 | + s->regs[R_DESCONF] = 0x02D00111; | ||
809 | + s->regs[R_DESCONF2] = 0x2ab10000 | s->jumbo_max_len; | ||
810 | + s->regs[R_DESCONF5] = 0x002f2045; | ||
811 | + s->regs[R_DESCONF6] = GEM_DESCONF6_64B_MASK; | ||
812 | + s->regs[R_INT_Q1_MASK] = 0x00000CE6; | ||
813 | + s->regs[R_JUMBO_MAX_LEN] = s->jumbo_max_len; | ||
814 | |||
815 | if (s->num_priority_queues > 1) { | ||
816 | queues_mask = MAKE_64BIT_MASK(1, s->num_priority_queues - 1); | ||
817 | - s->regs[GEM_DESCONF6] |= queues_mask; | ||
818 | + s->regs[R_DESCONF6] |= queues_mask; | ||
819 | } | ||
820 | |||
821 | /* Set MAC address */ | ||
822 | a = &s->conf.macaddr.a[0]; | ||
823 | - s->regs[GEM_SPADDR1LO] = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24); | ||
824 | - s->regs[GEM_SPADDR1HI] = a[4] | (a[5] << 8); | ||
825 | + s->regs[R_SPADDR1LO] = a[0] | (a[1] << 8) | (a[2] << 16) | (a[3] << 24); | ||
826 | + s->regs[R_SPADDR1HI] = a[4] | (a[5] << 8); | ||
827 | |||
828 | for (i = 0; i < 4; i++) { | ||
829 | s->sar_active[i] = false; | ||
830 | @@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) | ||
831 | DB_PRINT("offset: 0x%04x read: 0x%08x\n", (unsigned)offset*4, retval); | ||
832 | |||
833 | switch (offset) { | ||
834 | - case GEM_ISR: | ||
835 | + case R_ISR: | ||
836 | DB_PRINT("lowering irqs on ISR read\n"); | ||
837 | /* The interrupts get updated at the end of the function. */ | ||
838 | break; | ||
839 | - case GEM_PHYMNTNC: | ||
840 | + case R_PHYMNTNC: | ||
841 | if (retval & GEM_PHYMNTNC_OP_R) { | ||
842 | uint32_t phy_addr, reg_num; | ||
843 | |||
844 | @@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, | ||
845 | |||
846 | /* Handle register write side effects */ | ||
847 | switch (offset) { | ||
848 | - case GEM_NWCTRL: | ||
849 | + case R_NWCTRL: | ||
850 | if (val & GEM_NWCTRL_RXENA) { | ||
851 | for (i = 0; i < s->num_priority_queues; ++i) { | ||
852 | gem_get_rx_desc(s, i); | ||
853 | @@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, | ||
854 | } | ||
855 | break; | ||
856 | |||
857 | - case GEM_TXSTATUS: | ||
858 | + case R_TXSTATUS: | ||
859 | gem_update_int_status(s); | ||
860 | break; | ||
861 | - case GEM_RXQBASE: | ||
862 | + case R_RXQBASE: | ||
863 | s->rx_desc_addr[0] = val; | ||
864 | break; | ||
865 | - case GEM_RECEIVE_Q1_PTR ... GEM_RECEIVE_Q7_PTR: | ||
866 | - s->rx_desc_addr[offset - GEM_RECEIVE_Q1_PTR + 1] = val; | ||
867 | + case R_RECEIVE_Q1_PTR ... R_RECEIVE_Q7_PTR: | ||
868 | + s->rx_desc_addr[offset - R_RECEIVE_Q1_PTR + 1] = val; | ||
869 | break; | ||
870 | - case GEM_TXQBASE: | ||
871 | + case R_TXQBASE: | ||
872 | s->tx_desc_addr[0] = val; | ||
873 | break; | ||
874 | - case GEM_TRANSMIT_Q1_PTR ... GEM_TRANSMIT_Q7_PTR: | ||
875 | - s->tx_desc_addr[offset - GEM_TRANSMIT_Q1_PTR + 1] = val; | ||
876 | + case R_TRANSMIT_Q1_PTR ... R_TRANSMIT_Q7_PTR: | ||
877 | + s->tx_desc_addr[offset - R_TRANSMIT_Q1_PTR + 1] = val; | ||
878 | break; | ||
879 | - case GEM_RXSTATUS: | ||
880 | + case R_RXSTATUS: | ||
881 | gem_update_int_status(s); | ||
882 | break; | ||
883 | - case GEM_IER: | ||
884 | - s->regs[GEM_IMR] &= ~val; | ||
885 | + case R_IER: | ||
886 | + s->regs[R_IMR] &= ~val; | ||
887 | gem_update_int_status(s); | ||
888 | break; | ||
889 | - case GEM_JUMBO_MAX_LEN: | ||
890 | - s->regs[GEM_JUMBO_MAX_LEN] = val & MAX_JUMBO_FRAME_SIZE_MASK; | ||
891 | + case R_JUMBO_MAX_LEN: | ||
892 | + s->regs[R_JUMBO_MAX_LEN] = val & MAX_JUMBO_FRAME_SIZE_MASK; | ||
893 | break; | ||
894 | - case GEM_INT_Q1_ENABLE ... GEM_INT_Q7_ENABLE: | ||
895 | - s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_ENABLE] &= ~val; | ||
896 | + case R_INT_Q1_ENABLE ... R_INT_Q7_ENABLE: | ||
897 | + s->regs[R_INT_Q1_MASK + offset - R_INT_Q1_ENABLE] &= ~val; | ||
898 | gem_update_int_status(s); | ||
899 | break; | ||
900 | - case GEM_IDR: | ||
901 | - s->regs[GEM_IMR] |= val; | ||
902 | + case R_IDR: | ||
903 | + s->regs[R_IMR] |= val; | ||
904 | gem_update_int_status(s); | ||
905 | break; | ||
906 | - case GEM_INT_Q1_DISABLE ... GEM_INT_Q7_DISABLE: | ||
907 | - s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_DISABLE] |= val; | ||
908 | + case R_INT_Q1_DISABLE ... R_INT_Q7_DISABLE: | ||
909 | + s->regs[R_INT_Q1_MASK + offset - R_INT_Q1_DISABLE] |= val; | ||
910 | gem_update_int_status(s); | ||
911 | break; | ||
912 | - case GEM_SPADDR1LO: | ||
913 | - case GEM_SPADDR2LO: | ||
914 | - case GEM_SPADDR3LO: | ||
915 | - case GEM_SPADDR4LO: | ||
916 | - s->sar_active[(offset - GEM_SPADDR1LO) / 2] = false; | ||
917 | + case R_SPADDR1LO: | ||
918 | + case R_SPADDR2LO: | ||
919 | + case R_SPADDR3LO: | ||
920 | + case R_SPADDR4LO: | ||
921 | + s->sar_active[(offset - R_SPADDR1LO) / 2] = false; | ||
922 | break; | ||
923 | - case GEM_SPADDR1HI: | ||
924 | - case GEM_SPADDR2HI: | ||
925 | - case GEM_SPADDR3HI: | ||
926 | - case GEM_SPADDR4HI: | ||
927 | - s->sar_active[(offset - GEM_SPADDR1HI) / 2] = true; | ||
928 | + case R_SPADDR1HI: | ||
929 | + case R_SPADDR2HI: | ||
930 | + case R_SPADDR3HI: | ||
931 | + case R_SPADDR4HI: | ||
932 | + s->sar_active[(offset - R_SPADDR1HI) / 2] = true; | ||
933 | break; | ||
934 | - case GEM_PHYMNTNC: | ||
935 | + case R_PHYMNTNC: | ||
936 | if (val & GEM_PHYMNTNC_OP_W) { | ||
937 | uint32_t phy_addr, reg_num; | ||
158 | 938 | ||
159 | -- | 939 | -- |
160 | 2.20.1 | 940 | 2.34.1 |
161 | |||
162 | diff view generated by jsdifflib |
1 | From: Peter Collingbourne <pcc@google.com> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Section D6.7 of the ARM ARM states: | 3 | Describe screening registers fields using the FIELD macros. |
4 | 4 | ||
5 | For the purpose of determining Tag Check Fault handling, unprivileged | 5 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
6 | load and store instructions are treated as if executed at EL0 when | 6 | Reviewed-by: sai.pavan.boddu@amd.com |
7 | executed at either: | 7 | Message-id: 20231017194422.4124691-3-luc.michel@amd.com |
8 | - EL1, when the Effective value of PSTATE.UAO is 0. | ||
9 | - EL2, when both the Effective value of HCR_EL2.{E2H, TGE} is {1, 1} | ||
10 | and the Effective value of PSTATE.UAO is 0. | ||
11 | |||
12 | ARM has confirmed a defect in the pseudocode function | ||
13 | AArch64.TagCheckFault that makes it inconsistent with the above | ||
14 | wording. The remedy is to adjust references to PSTATE.EL in that | ||
15 | function to instead refer to AArch64.AccessUsesEL(acctype), so | ||
16 | that unprivileged instructions use SCTLR_EL1.TCF0 and TFSRE0_EL1. | ||
17 | The exception type for synchronous tag check faults remains unchanged. | ||
18 | |||
19 | This patch implements the described change by partially reverting | ||
20 | commits 50244cc76abc and cc97b0019bb5. | ||
21 | |||
22 | Signed-off-by: Peter Collingbourne <pcc@google.com> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20210219201820.2672077-1-pcc@google.com | ||
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
27 | --- | 9 | --- |
28 | target/arm/helper.c | 2 +- | 10 | hw/net/cadence_gem.c | 94 ++++++++++++++++++++++---------------------- |
29 | target/arm/mte_helper.c | 13 +++++++++---- | 11 | 1 file changed, 48 insertions(+), 46 deletions(-) |
30 | 2 files changed, 10 insertions(+), 5 deletions(-) | ||
31 | 12 | ||
32 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
33 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/helper.c | 15 | --- a/hw/net/cadence_gem.c |
35 | +++ b/target/arm/helper.c | 16 | +++ b/hw/net/cadence_gem.c |
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | 17 | @@ -XXX,XX +XXX,XX @@ REG32(INT_Q1_DISABLE, 0x620) |
37 | if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | 18 | REG32(INT_Q7_DISABLE, 0x638) |
38 | && tbid | 19 | |
39 | && !(env->pstate & PSTATE_TCO) | 20 | REG32(SCREENING_TYPE1_REG0, 0x500) |
40 | - && (sctlr & SCTLR_TCF) | 21 | - |
41 | + && (sctlr & SCTLR_TCF0) | 22 | -#define GEM_ST1R_UDP_PORT_MATCH_ENABLE (1 << 29) |
42 | && allocation_tag_access_enabled(env, 0, sctlr)) { | 23 | -#define GEM_ST1R_DSTC_ENABLE (1 << 28) |
43 | flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | 24 | -#define GEM_ST1R_UDP_PORT_MATCH_SHIFT (12) |
25 | -#define GEM_ST1R_UDP_PORT_MATCH_WIDTH (27 - GEM_ST1R_UDP_PORT_MATCH_SHIFT + 1) | ||
26 | -#define GEM_ST1R_DSTC_MATCH_SHIFT (4) | ||
27 | -#define GEM_ST1R_DSTC_MATCH_WIDTH (11 - GEM_ST1R_DSTC_MATCH_SHIFT + 1) | ||
28 | -#define GEM_ST1R_QUEUE_SHIFT (0) | ||
29 | -#define GEM_ST1R_QUEUE_WIDTH (3 - GEM_ST1R_QUEUE_SHIFT + 1) | ||
30 | + FIELD(SCREENING_TYPE1_REG0, QUEUE_NUM, 0, 4) | ||
31 | + FIELD(SCREENING_TYPE1_REG0, DSTC_MATCH, 4, 8) | ||
32 | + FIELD(SCREENING_TYPE1_REG0, UDP_PORT_MATCH, 12, 16) | ||
33 | + FIELD(SCREENING_TYPE1_REG0, DSTC_ENABLE, 28, 1) | ||
34 | + FIELD(SCREENING_TYPE1_REG0, UDP_PORT_MATCH_EN, 29, 1) | ||
35 | + FIELD(SCREENING_TYPE1_REG0, DROP_ON_MATCH, 30, 1) | ||
36 | |||
37 | REG32(SCREENING_TYPE2_REG0, 0x540) | ||
38 | - | ||
39 | -#define GEM_ST2R_COMPARE_A_ENABLE (1 << 18) | ||
40 | -#define GEM_ST2R_COMPARE_A_SHIFT (13) | ||
41 | -#define GEM_ST2R_COMPARE_WIDTH (17 - GEM_ST2R_COMPARE_A_SHIFT + 1) | ||
42 | -#define GEM_ST2R_ETHERTYPE_ENABLE (1 << 12) | ||
43 | -#define GEM_ST2R_ETHERTYPE_INDEX_SHIFT (9) | ||
44 | -#define GEM_ST2R_ETHERTYPE_INDEX_WIDTH (11 - GEM_ST2R_ETHERTYPE_INDEX_SHIFT \ | ||
45 | - + 1) | ||
46 | -#define GEM_ST2R_QUEUE_SHIFT (0) | ||
47 | -#define GEM_ST2R_QUEUE_WIDTH (3 - GEM_ST2R_QUEUE_SHIFT + 1) | ||
48 | + FIELD(SCREENING_TYPE2_REG0, QUEUE_NUM, 0, 4) | ||
49 | + FIELD(SCREENING_TYPE2_REG0, VLAN_PRIORITY, 4, 3) | ||
50 | + FIELD(SCREENING_TYPE2_REG0, VLAN_ENABLE, 8, 1) | ||
51 | + FIELD(SCREENING_TYPE2_REG0, ETHERTYPE_REG_INDEX, 9, 3) | ||
52 | + FIELD(SCREENING_TYPE2_REG0, ETHERTYPE_ENABLE, 12, 1) | ||
53 | + FIELD(SCREENING_TYPE2_REG0, COMPARE_A, 13, 5) | ||
54 | + FIELD(SCREENING_TYPE2_REG0, COMPARE_A_ENABLE, 18, 1) | ||
55 | + FIELD(SCREENING_TYPE2_REG0, COMPARE_B, 19, 5) | ||
56 | + FIELD(SCREENING_TYPE2_REG0, COMPARE_B_ENABLE, 24, 1) | ||
57 | + FIELD(SCREENING_TYPE2_REG0, COMPARE_C, 25, 5) | ||
58 | + FIELD(SCREENING_TYPE2_REG0, COMPARE_C_ENABLE, 30, 1) | ||
59 | + FIELD(SCREENING_TYPE2_REG0, DROP_ON_MATCH, 31, 1) | ||
60 | |||
61 | REG32(SCREENING_TYPE2_ETHERTYPE_REG0, 0x6e0) | ||
62 | -REG32(TYPE2_COMPARE_0_WORD_0, 0x700) | ||
63 | |||
64 | -#define GEM_T2CW1_COMPARE_OFFSET_SHIFT (7) | ||
65 | -#define GEM_T2CW1_COMPARE_OFFSET_WIDTH (8 - GEM_T2CW1_COMPARE_OFFSET_SHIFT + 1) | ||
66 | -#define GEM_T2CW1_OFFSET_VALUE_SHIFT (0) | ||
67 | -#define GEM_T2CW1_OFFSET_VALUE_WIDTH (6 - GEM_T2CW1_OFFSET_VALUE_SHIFT + 1) | ||
68 | +REG32(TYPE2_COMPARE_0_WORD_0, 0x700) | ||
69 | + FIELD(TYPE2_COMPARE_0_WORD_0, MASK_VALUE, 0, 16) | ||
70 | + FIELD(TYPE2_COMPARE_0_WORD_0, COMPARE_VALUE, 16, 16) | ||
71 | + | ||
72 | +REG32(TYPE2_COMPARE_0_WORD_1, 0x704) | ||
73 | + FIELD(TYPE2_COMPARE_0_WORD_1, OFFSET_VALUE, 0, 7) | ||
74 | + FIELD(TYPE2_COMPARE_0_WORD_1, COMPARE_OFFSET, 7, 2) | ||
75 | + FIELD(TYPE2_COMPARE_0_WORD_1, DISABLE_MASK, 9, 1) | ||
76 | + FIELD(TYPE2_COMPARE_0_WORD_1, COMPARE_VLAN_ID, 10, 1) | ||
77 | |||
78 | /*****************************************/ | ||
79 | #define GEM_NWCTRL_TXSTART 0x00000200 /* Transmit Enable */ | ||
80 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
81 | mismatched = false; | ||
82 | |||
83 | /* Screening is based on UDP Port */ | ||
84 | - if (reg & GEM_ST1R_UDP_PORT_MATCH_ENABLE) { | ||
85 | + if (FIELD_EX32(reg, SCREENING_TYPE1_REG0, UDP_PORT_MATCH_EN)) { | ||
86 | uint16_t udp_port = rxbuf_ptr[14 + 22] << 8 | rxbuf_ptr[14 + 23]; | ||
87 | - if (udp_port == extract32(reg, GEM_ST1R_UDP_PORT_MATCH_SHIFT, | ||
88 | - GEM_ST1R_UDP_PORT_MATCH_WIDTH)) { | ||
89 | + if (udp_port == FIELD_EX32(reg, SCREENING_TYPE1_REG0, UDP_PORT_MATCH)) { | ||
90 | matched = true; | ||
91 | } else { | ||
92 | mismatched = true; | ||
93 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
44 | } | 94 | } |
45 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | 95 | |
46 | index XXXXXXX..XXXXXXX 100644 | 96 | /* Screening is based on DS/TC */ |
47 | --- a/target/arm/mte_helper.c | 97 | - if (reg & GEM_ST1R_DSTC_ENABLE) { |
48 | +++ b/target/arm/mte_helper.c | 98 | + if (FIELD_EX32(reg, SCREENING_TYPE1_REG0, DSTC_ENABLE)) { |
49 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | 99 | uint8_t dscp = rxbuf_ptr[14 + 1]; |
50 | reg_el = regime_el(env, arm_mmu_idx); | 100 | - if (dscp == extract32(reg, GEM_ST1R_DSTC_MATCH_SHIFT, |
51 | sctlr = env->cp15.sctlr_el[reg_el]; | 101 | - GEM_ST1R_DSTC_MATCH_WIDTH)) { |
52 | 102 | + if (dscp == FIELD_EX32(reg, SCREENING_TYPE1_REG0, DSTC_MATCH)) { | |
53 | - el = arm_current_el(env); | 103 | matched = true; |
54 | - if (el == 0) { | 104 | } else { |
55 | + switch (arm_mmu_idx) { | 105 | mismatched = true; |
56 | + case ARMMMUIdx_E10_0: | 106 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, |
57 | + case ARMMMUIdx_E20_0: | 107 | } |
58 | + el = 0; | 108 | |
59 | tcf = extract64(sctlr, 38, 2); | 109 | if (matched && !mismatched) { |
60 | - } else { | 110 | - return extract32(reg, GEM_ST1R_QUEUE_SHIFT, GEM_ST1R_QUEUE_WIDTH); |
61 | + break; | 111 | + return FIELD_EX32(reg, SCREENING_TYPE1_REG0, QUEUE_NUM); |
62 | + default: | 112 | } |
63 | + el = reg_el; | ||
64 | tcf = extract64(sctlr, 40, 2); | ||
65 | } | 113 | } |
66 | 114 | ||
67 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | 115 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, |
68 | env->exception.vaddress = dirty_ptr; | 116 | matched = false; |
69 | 117 | mismatched = false; | |
70 | is_write = FIELD_EX32(desc, MTEDESC, WRITE); | 118 | |
71 | - syn = syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, is_write, 0x11); | 119 | - if (reg & GEM_ST2R_ETHERTYPE_ENABLE) { |
72 | + syn = syn_data_abort_no_iss(arm_current_el(env) != 0, 0, 0, 0, 0, | 120 | + if (FIELD_EX32(reg, SCREENING_TYPE2_REG0, ETHERTYPE_ENABLE)) { |
73 | + is_write, 0x11); | 121 | uint16_t type = rxbuf_ptr[12] << 8 | rxbuf_ptr[13]; |
74 | raise_exception(env, EXCP_DATA_ABORT, syn, exception_target_el(env)); | 122 | - int et_idx = extract32(reg, GEM_ST2R_ETHERTYPE_INDEX_SHIFT, |
75 | /* noreturn, but fall through to the assert anyway */ | 123 | - GEM_ST2R_ETHERTYPE_INDEX_WIDTH); |
124 | + int et_idx = FIELD_EX32(reg, SCREENING_TYPE2_REG0, | ||
125 | + ETHERTYPE_REG_INDEX); | ||
126 | |||
127 | if (et_idx > s->num_type2_screeners) { | ||
128 | qemu_log_mask(LOG_GUEST_ERROR, "Out of range ethertype " | ||
129 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
130 | |||
131 | /* Compare A, B, C */ | ||
132 | for (j = 0; j < 3; j++) { | ||
133 | - uint32_t cr0, cr1, mask; | ||
134 | + uint32_t cr0, cr1, mask, compare; | ||
135 | uint16_t rx_cmp; | ||
136 | int offset; | ||
137 | - int cr_idx = extract32(reg, GEM_ST2R_COMPARE_A_SHIFT + j * 6, | ||
138 | - GEM_ST2R_COMPARE_WIDTH); | ||
139 | + int cr_idx = extract32(reg, R_SCREENING_TYPE2_REG0_COMPARE_A_SHIFT + j * 6, | ||
140 | + R_SCREENING_TYPE2_REG0_COMPARE_A_LENGTH); | ||
141 | |||
142 | - if (!(reg & (GEM_ST2R_COMPARE_A_ENABLE << (j * 6)))) { | ||
143 | + if (!extract32(reg, R_SCREENING_TYPE2_REG0_COMPARE_A_ENABLE_SHIFT + j * 6, | ||
144 | + R_SCREENING_TYPE2_REG0_COMPARE_A_ENABLE_LENGTH)) { | ||
145 | continue; | ||
146 | } | ||
147 | + | ||
148 | if (cr_idx > s->num_type2_screeners) { | ||
149 | qemu_log_mask(LOG_GUEST_ERROR, "Out of range compare " | ||
150 | "register index: %d\n", cr_idx); | ||
151 | } | ||
152 | |||
153 | cr0 = s->regs[R_TYPE2_COMPARE_0_WORD_0 + cr_idx * 2]; | ||
154 | - cr1 = s->regs[R_TYPE2_COMPARE_0_WORD_0 + cr_idx * 2 + 1]; | ||
155 | - offset = extract32(cr1, GEM_T2CW1_OFFSET_VALUE_SHIFT, | ||
156 | - GEM_T2CW1_OFFSET_VALUE_WIDTH); | ||
157 | + cr1 = s->regs[R_TYPE2_COMPARE_0_WORD_1 + cr_idx * 2]; | ||
158 | + offset = FIELD_EX32(cr1, TYPE2_COMPARE_0_WORD_1, OFFSET_VALUE); | ||
159 | |||
160 | - switch (extract32(cr1, GEM_T2CW1_COMPARE_OFFSET_SHIFT, | ||
161 | - GEM_T2CW1_COMPARE_OFFSET_WIDTH)) { | ||
162 | + switch (FIELD_EX32(cr1, TYPE2_COMPARE_0_WORD_1, COMPARE_OFFSET)) { | ||
163 | case 3: /* Skip UDP header */ | ||
164 | qemu_log_mask(LOG_UNIMP, "TCP compare offsets" | ||
165 | "unimplemented - assuming UDP\n"); | ||
166 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
167 | } | ||
168 | |||
169 | rx_cmp = rxbuf_ptr[offset] << 8 | rxbuf_ptr[offset]; | ||
170 | - mask = extract32(cr0, 0, 16); | ||
171 | + mask = FIELD_EX32(cr0, TYPE2_COMPARE_0_WORD_0, MASK_VALUE); | ||
172 | + compare = FIELD_EX32(cr0, TYPE2_COMPARE_0_WORD_0, COMPARE_VALUE); | ||
173 | |||
174 | - if ((rx_cmp & mask) == (extract32(cr0, 16, 16) & mask)) { | ||
175 | + if ((rx_cmp & mask) == (compare & mask)) { | ||
176 | matched = true; | ||
177 | } else { | ||
178 | mismatched = true; | ||
179 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
180 | } | ||
181 | |||
182 | if (matched && !mismatched) { | ||
183 | - return extract32(reg, GEM_ST2R_QUEUE_SHIFT, GEM_ST2R_QUEUE_WIDTH); | ||
184 | + return FIELD_EX32(reg, SCREENING_TYPE2_REG0, QUEUE_NUM); | ||
185 | } | ||
186 | } | ||
76 | 187 | ||
77 | -- | 188 | -- |
78 | 2.20.1 | 189 | 2.34.1 |
79 | |||
80 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Always perform one call instead of two for 16-byte operands. | 3 | Use the FIELD macro to describe the NWCTRL register fields. |
4 | Use byte loads/stores directly into the vector register file | ||
5 | instead of extractions and deposits to a 64-bit local variable. | ||
6 | 4 | ||
7 | In order to easily receive pointers into the vector register file, | 5 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
8 | convert the helper to the gvec out-of-line signature. Move the | 6 | Reviewed-by: sai.pavan.boddu@amd.com |
9 | helper into vec_helper.c, where it can make use of H1 and clear_tail. | 7 | Message-id: 20231017194422.4124691-4-luc.michel@amd.com |
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Message-id: 20210224230532.276878-1-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 9 | --- |
17 | target/arm/helper-a64.h | 2 +- | 10 | hw/net/cadence_gem.c | 53 +++++++++++++++++++++++++++++++++----------- |
18 | target/arm/helper-a64.c | 32 --------------------- | 11 | 1 file changed, 40 insertions(+), 13 deletions(-) |
19 | target/arm/translate-a64.c | 58 +++++--------------------------------- | ||
20 | target/arm/vec_helper.c | 48 +++++++++++++++++++++++++++++++ | ||
21 | 4 files changed, 56 insertions(+), 84 deletions(-) | ||
22 | 12 | ||
23 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
24 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/helper-a64.h | 15 | --- a/hw/net/cadence_gem.c |
26 | +++ b/target/arm/helper-a64.h | 16 | +++ b/hw/net/cadence_gem.c |
27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) | 17 | @@ -XXX,XX +XXX,XX @@ |
28 | DEF_HELPER_3(vfp_cmpes_a64, i64, f32, f32, ptr) | 18 | } while (0) |
29 | DEF_HELPER_3(vfp_cmpd_a64, i64, f64, f64, ptr) | 19 | |
30 | DEF_HELPER_3(vfp_cmped_a64, i64, f64, f64, ptr) | 20 | REG32(NWCTRL, 0x0) /* Network Control reg */ |
31 | -DEF_HELPER_FLAGS_5(simd_tbl, TCG_CALL_NO_RWG_SE, i64, env, i64, i64, i32, i32) | 21 | + FIELD(NWCTRL, LOOPBACK , 0, 1) |
32 | +DEF_HELPER_FLAGS_4(simd_tblx, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 22 | + FIELD(NWCTRL, LOOPBACK_LOCAL , 1, 1) |
33 | DEF_HELPER_FLAGS_3(vfp_mulxs, TCG_CALL_NO_RWG, f32, f32, f32, ptr) | 23 | + FIELD(NWCTRL, ENABLE_RECEIVE, 2, 1) |
34 | DEF_HELPER_FLAGS_3(vfp_mulxd, TCG_CALL_NO_RWG, f64, f64, f64, ptr) | 24 | + FIELD(NWCTRL, ENABLE_TRANSMIT, 3, 1) |
35 | DEF_HELPER_FLAGS_3(neon_ceq_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) | 25 | + FIELD(NWCTRL, MAN_PORT_EN , 4, 1) |
36 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 26 | + FIELD(NWCTRL, CLEAR_ALL_STATS_REGS , 5, 1) |
37 | index XXXXXXX..XXXXXXX 100644 | 27 | + FIELD(NWCTRL, INC_ALL_STATS_REGS, 6, 1) |
38 | --- a/target/arm/helper-a64.c | 28 | + FIELD(NWCTRL, STATS_WRITE_EN, 7, 1) |
39 | +++ b/target/arm/helper-a64.c | 29 | + FIELD(NWCTRL, BACK_PRESSURE, 8, 1) |
40 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_mulxd)(float64 a, float64 b, void *fpstp) | 30 | + FIELD(NWCTRL, TRANSMIT_START , 9, 1) |
41 | return float64_mul(a, b, fpst); | 31 | + FIELD(NWCTRL, TRANSMIT_HALT, 10, 1) |
42 | } | 32 | + FIELD(NWCTRL, TX_PAUSE_FRAME_RE, 11, 1) |
43 | 33 | + FIELD(NWCTRL, TX_PAUSE_FRAME_ZE, 12, 1) | |
44 | -uint64_t HELPER(simd_tbl)(CPUARMState *env, uint64_t result, uint64_t indices, | 34 | + FIELD(NWCTRL, STATS_TAKE_SNAP, 13, 1) |
45 | - uint32_t rn, uint32_t numregs) | 35 | + FIELD(NWCTRL, STATS_READ_SNAP, 14, 1) |
46 | -{ | 36 | + FIELD(NWCTRL, STORE_RX_TS, 15, 1) |
47 | - /* Helper function for SIMD TBL and TBX. We have to do the table | 37 | + FIELD(NWCTRL, PFC_ENABLE, 16, 1) |
48 | - * lookup part for the 64 bits worth of indices we're passed in. | 38 | + FIELD(NWCTRL, PFC_PRIO_BASED, 17, 1) |
49 | - * result is the initial results vector (either zeroes for TBL | 39 | + FIELD(NWCTRL, FLUSH_RX_PKT_PCLK , 18, 1) |
50 | - * or some guest values for TBX), rn the register number where | 40 | + FIELD(NWCTRL, TX_LPI_EN, 19, 1) |
51 | - * the table starts, and numregs the number of registers in the table. | 41 | + FIELD(NWCTRL, PTP_UNICAST_ENA, 20, 1) |
52 | - * We return the results of the lookups. | 42 | + FIELD(NWCTRL, ALT_SGMII_MODE, 21, 1) |
53 | - */ | 43 | + FIELD(NWCTRL, STORE_UDP_OFFSET, 22, 1) |
54 | - int shift; | 44 | + FIELD(NWCTRL, EXT_TSU_PORT_EN, 23, 1) |
45 | + FIELD(NWCTRL, ONE_STEP_SYNC_MO, 24, 1) | ||
46 | + FIELD(NWCTRL, PFC_CTRL , 25, 1) | ||
47 | + FIELD(NWCTRL, EXT_RXQ_SEL_EN , 26, 1) | ||
48 | + FIELD(NWCTRL, OSS_CORRECTION_FIELD, 27, 1) | ||
49 | + FIELD(NWCTRL, SEL_MII_ON_RGMII, 28, 1) | ||
50 | + FIELD(NWCTRL, TWO_PT_FIVE_GIG, 29, 1) | ||
51 | + FIELD(NWCTRL, IFG_EATS_QAV_CREDIT, 30, 1) | ||
52 | + | ||
53 | REG32(NWCFG, 0x4) /* Network Config reg */ | ||
54 | REG32(NWSTATUS, 0x8) /* Network Status reg */ | ||
55 | REG32(USERIO, 0xc) /* User IO reg */ | ||
56 | @@ -XXX,XX +XXX,XX @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) | ||
57 | FIELD(TYPE2_COMPARE_0_WORD_1, COMPARE_VLAN_ID, 10, 1) | ||
58 | |||
59 | /*****************************************/ | ||
60 | -#define GEM_NWCTRL_TXSTART 0x00000200 /* Transmit Enable */ | ||
61 | -#define GEM_NWCTRL_TXENA 0x00000008 /* Transmit Enable */ | ||
62 | -#define GEM_NWCTRL_RXENA 0x00000004 /* Receive Enable */ | ||
63 | -#define GEM_NWCTRL_LOCALLOOP 0x00000002 /* Local Loopback */ | ||
55 | - | 64 | - |
56 | - for (shift = 0; shift < 64; shift += 8) { | 65 | #define GEM_NWCFG_STRIP_FCS 0x00020000 /* Strip FCS field */ |
57 | - int index = extract64(indices, shift, 8); | 66 | #define GEM_NWCFG_LERR_DISC 0x00010000 /* Discard RX frames with len err */ |
58 | - if (index < 16 * numregs) { | 67 | #define GEM_NWCFG_BUFF_OFST_M 0x0000C000 /* Receive buffer offset mask */ |
59 | - /* Convert index (a byte offset into the virtual table | 68 | @@ -XXX,XX +XXX,XX @@ static bool gem_can_receive(NetClientState *nc) |
60 | - * which is a series of 128-bit vectors concatenated) | 69 | s = qemu_get_nic_opaque(nc); |
61 | - * into the correct register element plus a bit offset | 70 | |
62 | - * into that element, bearing in mind that the table | 71 | /* Do nothing if receive is not enabled. */ |
63 | - * can wrap around from V31 to V0. | 72 | - if (!(s->regs[R_NWCTRL] & GEM_NWCTRL_RXENA)) { |
64 | - */ | 73 | + if (!FIELD_EX32(s->regs[R_NWCTRL], NWCTRL, ENABLE_RECEIVE)) { |
65 | - int elt = (rn * 2 + (index >> 3)) % 64; | 74 | if (s->can_rx_state != 1) { |
66 | - int bitidx = (index & 7) * 8; | 75 | s->can_rx_state = 1; |
67 | - uint64_t *q = aa64_vfp_qreg(env, elt >> 1); | 76 | DB_PRINT("can't receive - no enable\n"); |
68 | - uint64_t val = extract64(q[elt & 1], bitidx, 8); | 77 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
69 | - | 78 | int q = 0; |
70 | - result = deposit64(result, shift, 8, val); | 79 | |
71 | - } | 80 | /* Do nothing if transmit is not enabled. */ |
72 | - } | 81 | - if (!(s->regs[R_NWCTRL] & GEM_NWCTRL_TXENA)) { |
73 | - return result; | 82 | + if (!FIELD_EX32(s->regs[R_NWCTRL], NWCTRL, ENABLE_TRANSMIT)) { |
74 | -} | ||
75 | - | ||
76 | /* 64bit/double versions of the neon float compare functions */ | ||
77 | uint64_t HELPER(neon_ceq_f64)(float64 a, float64 b, void *fpstp) | ||
78 | { | ||
79 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/target/arm/translate-a64.c | ||
82 | +++ b/target/arm/translate-a64.c | ||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_tb(DisasContext *s, uint32_t insn) | ||
84 | int rm = extract32(insn, 16, 5); | ||
85 | int rn = extract32(insn, 5, 5); | ||
86 | int rd = extract32(insn, 0, 5); | ||
87 | - int is_tblx = extract32(insn, 12, 1); | ||
88 | - int len = extract32(insn, 13, 2); | ||
89 | - TCGv_i64 tcg_resl, tcg_resh, tcg_idx; | ||
90 | - TCGv_i32 tcg_regno, tcg_numregs; | ||
91 | + int is_tbx = extract32(insn, 12, 1); | ||
92 | + int len = (extract32(insn, 13, 2) + 1) * 16; | ||
93 | |||
94 | if (op2 != 0) { | ||
95 | unallocated_encoding(s); | ||
96 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_tb(DisasContext *s, uint32_t insn) | ||
97 | return; | 83 | return; |
98 | } | 84 | } |
99 | 85 | ||
100 | - /* This does a table lookup: for every byte element in the input | 86 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
101 | - * we index into a table formed from up to four vector registers, | 87 | while (tx_desc_get_used(desc) == 0) { |
102 | - * and then the output is the result of the lookups. Our helper | 88 | |
103 | - * function does the lookup operation for a single 64 bit part of | 89 | /* Do nothing if transmit is not enabled. */ |
104 | - * the input. | 90 | - if (!(s->regs[R_NWCTRL] & GEM_NWCTRL_TXENA)) { |
105 | - */ | 91 | + if (!FIELD_EX32(s->regs[R_NWCTRL], NWCTRL, ENABLE_TRANSMIT)) { |
106 | - tcg_resl = tcg_temp_new_i64(); | 92 | return; |
107 | - tcg_resh = NULL; | 93 | } |
108 | - | 94 | print_gem_tx_desc(desc, q); |
109 | - if (is_tblx) { | 95 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
110 | - read_vec_element(s, tcg_resl, rd, 0, MO_64); | 96 | gem_transmit_updatestats(s, s->tx_packet, total_bytes); |
111 | - } else { | 97 | |
112 | - tcg_gen_movi_i64(tcg_resl, 0); | 98 | /* Send the packet somewhere */ |
113 | - } | 99 | - if (s->phy_loop || (s->regs[R_NWCTRL] & |
114 | - | 100 | - GEM_NWCTRL_LOCALLOOP)) { |
115 | - if (is_q) { | 101 | + if (s->phy_loop || FIELD_EX32(s->regs[R_NWCTRL], NWCTRL, |
116 | - tcg_resh = tcg_temp_new_i64(); | 102 | + LOOPBACK_LOCAL)) { |
117 | - if (is_tblx) { | 103 | qemu_receive_packet(qemu_get_queue(s->nic), s->tx_packet, |
118 | - read_vec_element(s, tcg_resh, rd, 1, MO_64); | 104 | total_bytes); |
119 | - } else { | 105 | } else { |
120 | - tcg_gen_movi_i64(tcg_resh, 0); | 106 | @@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, |
121 | - } | 107 | /* Handle register write side effects */ |
122 | - } | 108 | switch (offset) { |
123 | - | 109 | case R_NWCTRL: |
124 | - tcg_idx = tcg_temp_new_i64(); | 110 | - if (val & GEM_NWCTRL_RXENA) { |
125 | - tcg_regno = tcg_const_i32(rn); | 111 | + if (FIELD_EX32(val, NWCTRL, ENABLE_RECEIVE)) { |
126 | - tcg_numregs = tcg_const_i32(len + 1); | 112 | for (i = 0; i < s->num_priority_queues; ++i) { |
127 | - read_vec_element(s, tcg_idx, rm, 0, MO_64); | 113 | gem_get_rx_desc(s, i); |
128 | - gen_helper_simd_tbl(tcg_resl, cpu_env, tcg_resl, tcg_idx, | 114 | } |
129 | - tcg_regno, tcg_numregs); | 115 | } |
130 | - if (is_q) { | 116 | - if (val & GEM_NWCTRL_TXSTART) { |
131 | - read_vec_element(s, tcg_idx, rm, 1, MO_64); | 117 | + if (FIELD_EX32(val, NWCTRL, TRANSMIT_START)) { |
132 | - gen_helper_simd_tbl(tcg_resh, cpu_env, tcg_resh, tcg_idx, | 118 | gem_transmit(s); |
133 | - tcg_regno, tcg_numregs); | 119 | } |
134 | - } | 120 | - if (!(val & GEM_NWCTRL_TXENA)) { |
135 | - tcg_temp_free_i64(tcg_idx); | 121 | + if (!(FIELD_EX32(val, NWCTRL, ENABLE_TRANSMIT))) { |
136 | - tcg_temp_free_i32(tcg_regno); | 122 | /* Reset to start of Q when transmit disabled. */ |
137 | - tcg_temp_free_i32(tcg_numregs); | 123 | for (i = 0; i < s->num_priority_queues; i++) { |
138 | - | 124 | s->tx_desc_addr[i] = gem_get_tx_queue_base_addr(s, i); |
139 | - write_vec_element(s, tcg_resl, rd, 0, MO_64); | ||
140 | - tcg_temp_free_i64(tcg_resl); | ||
141 | - | ||
142 | - if (is_q) { | ||
143 | - write_vec_element(s, tcg_resh, rd, 1, MO_64); | ||
144 | - tcg_temp_free_i64(tcg_resh); | ||
145 | - } | ||
146 | - clear_vec_high(s, is_q, rd); | ||
147 | + tcg_gen_gvec_2_ptr(vec_full_reg_offset(s, rd), | ||
148 | + vec_full_reg_offset(s, rm), cpu_env, | ||
149 | + is_q ? 16 : 8, vec_full_reg_size(s), | ||
150 | + (len << 6) | (is_tbx << 5) | rn, | ||
151 | + gen_helper_simd_tblx); | ||
152 | } | ||
153 | |||
154 | /* ZIP/UZP/TRN | ||
155 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/target/arm/vec_helper.c | ||
158 | +++ b/target/arm/vec_helper.c | ||
159 | @@ -XXX,XX +XXX,XX @@ DO_VRINT_RMODE(gvec_vrint_rm_h, helper_rinth, uint16_t) | ||
160 | DO_VRINT_RMODE(gvec_vrint_rm_s, helper_rints, uint32_t) | ||
161 | |||
162 | #undef DO_VRINT_RMODE | ||
163 | + | ||
164 | +#ifdef TARGET_AARCH64 | ||
165 | +void HELPER(simd_tblx)(void *vd, void *vm, void *venv, uint32_t desc) | ||
166 | +{ | ||
167 | + const uint8_t *indices = vm; | ||
168 | + CPUARMState *env = venv; | ||
169 | + size_t oprsz = simd_oprsz(desc); | ||
170 | + uint32_t rn = extract32(desc, SIMD_DATA_SHIFT, 5); | ||
171 | + bool is_tbx = extract32(desc, SIMD_DATA_SHIFT + 5, 1); | ||
172 | + uint32_t table_len = desc >> (SIMD_DATA_SHIFT + 6); | ||
173 | + union { | ||
174 | + uint8_t b[16]; | ||
175 | + uint64_t d[2]; | ||
176 | + } result; | ||
177 | + | ||
178 | + /* | ||
179 | + * We must construct the final result in a temp, lest the output | ||
180 | + * overlaps the input table. For TBL, begin with zero; for TBX, | ||
181 | + * begin with the original register contents. Note that we always | ||
182 | + * copy 16 bytes here to avoid an extra branch; clearing the high | ||
183 | + * bits of the register for oprsz == 8 is handled below. | ||
184 | + */ | ||
185 | + if (is_tbx) { | ||
186 | + memcpy(&result, vd, 16); | ||
187 | + } else { | ||
188 | + memset(&result, 0, 16); | ||
189 | + } | ||
190 | + | ||
191 | + for (size_t i = 0; i < oprsz; ++i) { | ||
192 | + uint32_t index = indices[H1(i)]; | ||
193 | + | ||
194 | + if (index < table_len) { | ||
195 | + /* | ||
196 | + * Convert index (a byte offset into the virtual table | ||
197 | + * which is a series of 128-bit vectors concatenated) | ||
198 | + * into the correct register element, bearing in mind | ||
199 | + * that the table can wrap around from V31 to V0. | ||
200 | + */ | ||
201 | + const uint8_t *table = (const uint8_t *) | ||
202 | + aa64_vfp_qreg(env, (rn + (index >> 4)) % 32); | ||
203 | + result.b[H1(i)] = table[H1(index % 16)]; | ||
204 | + } | ||
205 | + } | ||
206 | + | ||
207 | + memcpy(vd, &result, 16); | ||
208 | + clear_tail(vd, oprsz, simd_maxsz(desc)); | ||
209 | +} | ||
210 | +#endif | ||
211 | -- | 125 | -- |
212 | 2.20.1 | 126 | 2.34.1 |
213 | |||
214 | diff view generated by jsdifflib |
1 | For a long time now the UI layer has guaranteed that the console | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | surface is always 32 bits per pixel RGB. Remove the legacy dead | ||
3 | code from the milkymist display device which was handling the | ||
4 | possibility that the console surface was some other format. | ||
5 | 2 | ||
3 | Use de FIELD macro to describe the NWCFG register fields. | ||
4 | |||
5 | Signed-off-by: Luc Michel <luc.michel@amd.com> | ||
6 | Reviewed-by: sai.pavan.boddu@amd.com | ||
7 | Message-id: 20231017194422.4124691-5-luc.michel@amd.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210215103215.4944-2-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | hw/arm/musicpal.c | 64 ++++++++++++++++++----------------------------- | 10 | hw/net/cadence_gem.c | 60 ++++++++++++++++++++++++++++---------------- |
11 | 1 file changed, 24 insertions(+), 40 deletions(-) | 11 | 1 file changed, 39 insertions(+), 21 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/musicpal.c | 15 | --- a/hw/net/cadence_gem.c |
16 | +++ b/hw/arm/musicpal.c | 16 | +++ b/hw/net/cadence_gem.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint8_t scale_lcd_color(musicpal_lcd_state *s, uint8_t col) | 17 | @@ -XXX,XX +XXX,XX @@ REG32(NWCTRL, 0x0) /* Network Control reg */ |
18 | FIELD(NWCTRL, IFG_EATS_QAV_CREDIT, 30, 1) | ||
19 | |||
20 | REG32(NWCFG, 0x4) /* Network Config reg */ | ||
21 | + FIELD(NWCFG, SPEED, 0, 1) | ||
22 | + FIELD(NWCFG, FULL_DUPLEX, 1, 1) | ||
23 | + FIELD(NWCFG, DISCARD_NON_VLAN_FRAMES, 2, 1) | ||
24 | + FIELD(NWCFG, JUMBO_FRAMES, 3, 1) | ||
25 | + FIELD(NWCFG, PROMISC, 4, 1) | ||
26 | + FIELD(NWCFG, NO_BROADCAST, 5, 1) | ||
27 | + FIELD(NWCFG, MULTICAST_HASH_EN, 6, 1) | ||
28 | + FIELD(NWCFG, UNICAST_HASH_EN, 7, 1) | ||
29 | + FIELD(NWCFG, RECV_1536_BYTE_FRAMES, 8, 1) | ||
30 | + FIELD(NWCFG, EXTERNAL_ADDR_MATCH_EN, 9, 1) | ||
31 | + FIELD(NWCFG, GIGABIT_MODE_ENABLE, 10, 1) | ||
32 | + FIELD(NWCFG, PCS_SELECT, 11, 1) | ||
33 | + FIELD(NWCFG, RETRY_TEST, 12, 1) | ||
34 | + FIELD(NWCFG, PAUSE_ENABLE, 13, 1) | ||
35 | + FIELD(NWCFG, RECV_BUF_OFFSET, 14, 2) | ||
36 | + FIELD(NWCFG, LEN_ERR_DISCARD, 16, 1) | ||
37 | + FIELD(NWCFG, FCS_REMOVE, 17, 1) | ||
38 | + FIELD(NWCFG, MDC_CLOCK_DIV, 18, 3) | ||
39 | + FIELD(NWCFG, DATA_BUS_WIDTH, 21, 2) | ||
40 | + FIELD(NWCFG, DISABLE_COPY_PAUSE_FRAMES, 23, 1) | ||
41 | + FIELD(NWCFG, RECV_CSUM_OFFLOAD_EN, 24, 1) | ||
42 | + FIELD(NWCFG, EN_HALF_DUPLEX_RX, 25, 1) | ||
43 | + FIELD(NWCFG, IGNORE_RX_FCS, 26, 1) | ||
44 | + FIELD(NWCFG, SGMII_MODE_ENABLE, 27, 1) | ||
45 | + FIELD(NWCFG, IPG_STRETCH_ENABLE, 28, 1) | ||
46 | + FIELD(NWCFG, NSP_ACCEPT, 29, 1) | ||
47 | + FIELD(NWCFG, IGNORE_IPG_RX_ER, 30, 1) | ||
48 | + FIELD(NWCFG, UNI_DIRECTION_ENABLE, 31, 1) | ||
49 | + | ||
50 | REG32(NWSTATUS, 0x8) /* Network Status reg */ | ||
51 | REG32(USERIO, 0xc) /* User IO reg */ | ||
52 | REG32(DMACFG, 0x10) /* DMA Control reg */ | ||
53 | @@ -XXX,XX +XXX,XX @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) | ||
54 | FIELD(TYPE2_COMPARE_0_WORD_1, COMPARE_VLAN_ID, 10, 1) | ||
55 | |||
56 | /*****************************************/ | ||
57 | -#define GEM_NWCFG_STRIP_FCS 0x00020000 /* Strip FCS field */ | ||
58 | -#define GEM_NWCFG_LERR_DISC 0x00010000 /* Discard RX frames with len err */ | ||
59 | -#define GEM_NWCFG_BUFF_OFST_M 0x0000C000 /* Receive buffer offset mask */ | ||
60 | -#define GEM_NWCFG_BUFF_OFST_S 14 /* Receive buffer offset shift */ | ||
61 | -#define GEM_NWCFG_RCV_1538 0x00000100 /* Receive 1538 bytes frame */ | ||
62 | -#define GEM_NWCFG_UCAST_HASH 0x00000080 /* accept unicast if hash match */ | ||
63 | -#define GEM_NWCFG_MCAST_HASH 0x00000040 /* accept multicast if hash match */ | ||
64 | -#define GEM_NWCFG_BCAST_REJ 0x00000020 /* Reject broadcast packets */ | ||
65 | -#define GEM_NWCFG_PROMISC 0x00000010 /* Accept all packets */ | ||
66 | -#define GEM_NWCFG_JUMBO_FRAME 0x00000008 /* Jumbo Frames enable */ | ||
67 | - | ||
68 | #define GEM_DMACFG_ADDR_64B (1U << 30) | ||
69 | #define GEM_DMACFG_TX_BD_EXT (1U << 29) | ||
70 | #define GEM_DMACFG_RX_BD_EXT (1U << 28) | ||
71 | @@ -XXX,XX +XXX,XX @@ static const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
72 | static uint32_t gem_get_max_buf_len(CadenceGEMState *s, bool tx) | ||
73 | { | ||
74 | uint32_t size; | ||
75 | - if (s->regs[R_NWCFG] & GEM_NWCFG_JUMBO_FRAME) { | ||
76 | + if (FIELD_EX32(s->regs[R_NWCFG], NWCFG, JUMBO_FRAMES)) { | ||
77 | size = s->regs[R_JUMBO_MAX_LEN]; | ||
78 | if (size > s->jumbo_max_len) { | ||
79 | size = s->jumbo_max_len; | ||
80 | @@ -XXX,XX +XXX,XX @@ static uint32_t gem_get_max_buf_len(CadenceGEMState *s, bool tx) | ||
81 | } else if (tx) { | ||
82 | size = 1518; | ||
83 | } else { | ||
84 | - size = s->regs[R_NWCFG] & GEM_NWCFG_RCV_1538 ? 1538 : 1518; | ||
85 | + size = FIELD_EX32(s->regs[R_NWCFG], | ||
86 | + NWCFG, RECV_1536_BYTE_FRAMES) ? 1538 : 1518; | ||
18 | } | 87 | } |
88 | return size; | ||
19 | } | 89 | } |
20 | 90 | @@ -XXX,XX +XXX,XX @@ static int gem_mac_address_filter(CadenceGEMState *s, const uint8_t *packet) | |
21 | -#define SET_LCD_PIXEL(depth, type) \ | 91 | int i, is_mc; |
22 | -static inline void glue(set_lcd_pixel, depth) \ | 92 | |
23 | - (musicpal_lcd_state *s, int x, int y, type col) \ | 93 | /* Promiscuous mode? */ |
24 | -{ \ | 94 | - if (s->regs[R_NWCFG] & GEM_NWCFG_PROMISC) { |
25 | - int dx, dy; \ | 95 | + if (FIELD_EX32(s->regs[R_NWCFG], NWCFG, PROMISC)) { |
26 | - DisplaySurface *surface = qemu_console_surface(s->con); \ | 96 | return GEM_RX_PROMISCUOUS_ACCEPT; |
27 | - type *pixel = &((type *) surface_data(surface))[(y * 128 * 3 + x) * 3]; \ | ||
28 | -\ | ||
29 | - for (dy = 0; dy < 3; dy++, pixel += 127 * 3) \ | ||
30 | - for (dx = 0; dx < 3; dx++, pixel++) \ | ||
31 | - *pixel = col; \ | ||
32 | +static inline void set_lcd_pixel32(musicpal_lcd_state *s, | ||
33 | + int x, int y, uint32_t col) | ||
34 | +{ | ||
35 | + int dx, dy; | ||
36 | + DisplaySurface *surface = qemu_console_surface(s->con); | ||
37 | + uint32_t *pixel = | ||
38 | + &((uint32_t *) surface_data(surface))[(y * 128 * 3 + x) * 3]; | ||
39 | + | ||
40 | + for (dy = 0; dy < 3; dy++, pixel += 127 * 3) { | ||
41 | + for (dx = 0; dx < 3; dx++, pixel++) { | ||
42 | + *pixel = col; | ||
43 | + } | ||
44 | + } | ||
45 | } | ||
46 | -SET_LCD_PIXEL(8, uint8_t) | ||
47 | -SET_LCD_PIXEL(16, uint16_t) | ||
48 | -SET_LCD_PIXEL(32, uint32_t) | ||
49 | |||
50 | static void lcd_refresh(void *opaque) | ||
51 | { | ||
52 | musicpal_lcd_state *s = opaque; | ||
53 | - DisplaySurface *surface = qemu_console_surface(s->con); | ||
54 | int x, y, col; | ||
55 | |||
56 | - switch (surface_bits_per_pixel(surface)) { | ||
57 | - case 0: | ||
58 | - return; | ||
59 | -#define LCD_REFRESH(depth, func) \ | ||
60 | - case depth: \ | ||
61 | - col = func(scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 16) & 0xff), \ | ||
62 | - scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 8) & 0xff), \ | ||
63 | - scale_lcd_color(s, MP_LCD_TEXTCOLOR & 0xff)); \ | ||
64 | - for (x = 0; x < 128; x++) { \ | ||
65 | - for (y = 0; y < 64; y++) { \ | ||
66 | - if (s->video_ram[x + (y/8)*128] & (1 << (y % 8))) { \ | ||
67 | - glue(set_lcd_pixel, depth)(s, x, y, col); \ | ||
68 | - } else { \ | ||
69 | - glue(set_lcd_pixel, depth)(s, x, y, 0); \ | ||
70 | - } \ | ||
71 | - } \ | ||
72 | - } \ | ||
73 | - break; | ||
74 | - LCD_REFRESH(8, rgb_to_pixel8) | ||
75 | - LCD_REFRESH(16, rgb_to_pixel16) | ||
76 | - LCD_REFRESH(32, (is_surface_bgr(surface) ? | ||
77 | - rgb_to_pixel32bgr : rgb_to_pixel32)) | ||
78 | - default: | ||
79 | - hw_error("unsupported colour depth %i\n", | ||
80 | - surface_bits_per_pixel(surface)); | ||
81 | + col = rgb_to_pixel32(scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 16) & 0xff), | ||
82 | + scale_lcd_color(s, (MP_LCD_TEXTCOLOR >> 8) & 0xff), | ||
83 | + scale_lcd_color(s, MP_LCD_TEXTCOLOR & 0xff)); | ||
84 | + for (x = 0; x < 128; x++) { | ||
85 | + for (y = 0; y < 64; y++) { | ||
86 | + if (s->video_ram[x + (y / 8) * 128] & (1 << (y % 8))) { | ||
87 | + set_lcd_pixel32(s, x, y, col); | ||
88 | + } else { | ||
89 | + set_lcd_pixel32(s, x, y, 0); | ||
90 | + } | ||
91 | + } | ||
92 | } | 97 | } |
93 | 98 | ||
94 | dpy_gfx_update(s->con, 0, 0, 128*3, 64*3); | 99 | if (!memcmp(packet, broadcast_addr, 6)) { |
100 | /* Reject broadcast packets? */ | ||
101 | - if (s->regs[R_NWCFG] & GEM_NWCFG_BCAST_REJ) { | ||
102 | + if (FIELD_EX32(s->regs[R_NWCFG], NWCFG, NO_BROADCAST)) { | ||
103 | return GEM_RX_REJECT; | ||
104 | } | ||
105 | return GEM_RX_BROADCAST_ACCEPT; | ||
106 | @@ -XXX,XX +XXX,XX @@ static int gem_mac_address_filter(CadenceGEMState *s, const uint8_t *packet) | ||
107 | |||
108 | /* Accept packets -w- hash match? */ | ||
109 | is_mc = is_multicast_ether_addr(packet); | ||
110 | - if ((is_mc && (s->regs[R_NWCFG] & GEM_NWCFG_MCAST_HASH)) || | ||
111 | - (!is_mc && (s->regs[R_NWCFG] & GEM_NWCFG_UCAST_HASH))) { | ||
112 | + if ((is_mc && (FIELD_EX32(s->regs[R_NWCFG], NWCFG, MULTICAST_HASH_EN))) || | ||
113 | + (!is_mc && FIELD_EX32(s->regs[R_NWCFG], NWCFG, UNICAST_HASH_EN))) { | ||
114 | uint64_t buckets; | ||
115 | unsigned hash_index; | ||
116 | |||
117 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
118 | } | ||
119 | |||
120 | /* Discard packets with receive length error enabled ? */ | ||
121 | - if (s->regs[R_NWCFG] & GEM_NWCFG_LERR_DISC) { | ||
122 | + if (FIELD_EX32(s->regs[R_NWCFG], NWCFG, LEN_ERR_DISCARD)) { | ||
123 | unsigned type_len; | ||
124 | |||
125 | /* Fish the ethertype / length field out of the RX packet */ | ||
126 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
127 | /* | ||
128 | * Determine configured receive buffer offset (probably 0) | ||
129 | */ | ||
130 | - rxbuf_offset = (s->regs[R_NWCFG] & GEM_NWCFG_BUFF_OFST_M) >> | ||
131 | - GEM_NWCFG_BUFF_OFST_S; | ||
132 | + rxbuf_offset = FIELD_EX32(s->regs[R_NWCFG], NWCFG, RECV_BUF_OFFSET); | ||
133 | |||
134 | /* The configure size of each receive buffer. Determines how many | ||
135 | * buffers needed to hold this packet. | ||
136 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
137 | } | ||
138 | |||
139 | /* Strip of FCS field ? (usually yes) */ | ||
140 | - if (s->regs[R_NWCFG] & GEM_NWCFG_STRIP_FCS) { | ||
141 | + if (FIELD_EX32(s->regs[R_NWCFG], NWCFG, FCS_REMOVE)) { | ||
142 | rxbuf_ptr = (void *)buf; | ||
143 | } else { | ||
144 | unsigned crc_val; | ||
95 | -- | 145 | -- |
96 | 2.20.1 | 146 | 2.34.1 |
97 | |||
98 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | IDAU is specific to M-profile. KVM only supports A-profile. | 3 | Use de FIELD macro to describe the DMACFG register fields. |
4 | Restrict this interface to TCG, as it is pointless (and | ||
5 | confusing) on a KVM-only build. | ||
6 | 4 | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: sai.pavan.boddu@amd.com |
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20231017194422.4124691-6-luc.michel@amd.com |
10 | Message-id: 20210221222617.2579610-2-f4bug@amsat.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | target/arm/cpu.c | 7 ------- | 10 | hw/net/cadence_gem.c | 48 ++++++++++++++++++++++++++++---------------- |
14 | target/arm/cpu_tcg.c | 8 ++++++++ | 11 | 1 file changed, 31 insertions(+), 17 deletions(-) |
15 | 2 files changed, 8 insertions(+), 7 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.c | 15 | --- a/hw/net/cadence_gem.c |
20 | +++ b/target/arm/cpu.c | 16 | +++ b/hw/net/cadence_gem.c |
21 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo arm_cpu_type_info = { | 17 | @@ -XXX,XX +XXX,XX @@ REG32(NWCFG, 0x4) /* Network Config reg */ |
22 | .class_init = arm_cpu_class_init, | 18 | |
23 | }; | 19 | REG32(NWSTATUS, 0x8) /* Network Status reg */ |
24 | 20 | REG32(USERIO, 0xc) /* User IO reg */ | |
25 | -static const TypeInfo idau_interface_type_info = { | 21 | + |
26 | - .name = TYPE_IDAU_INTERFACE, | 22 | REG32(DMACFG, 0x10) /* DMA Control reg */ |
27 | - .parent = TYPE_INTERFACE, | 23 | + FIELD(DMACFG, SEND_BCAST_TO_ALL_QS, 31, 1) |
28 | - .class_size = sizeof(IDAUInterfaceClass), | 24 | + FIELD(DMACFG, DMA_ADDR_BUS_WIDTH, 30, 1) |
29 | -}; | 25 | + FIELD(DMACFG, TX_BD_EXT_MODE_EN , 29, 1) |
30 | - | 26 | + FIELD(DMACFG, RX_BD_EXT_MODE_EN , 28, 1) |
31 | static void arm_cpu_register_types(void) | 27 | + FIELD(DMACFG, FORCE_MAX_AMBA_BURST_TX, 26, 1) |
28 | + FIELD(DMACFG, FORCE_MAX_AMBA_BURST_RX, 25, 1) | ||
29 | + FIELD(DMACFG, FORCE_DISCARD_ON_ERR, 24, 1) | ||
30 | + FIELD(DMACFG, RX_BUF_SIZE, 16, 8) | ||
31 | + FIELD(DMACFG, CRC_ERROR_REPORT, 13, 1) | ||
32 | + FIELD(DMACFG, INF_LAST_DBUF_SIZE_EN, 12, 1) | ||
33 | + FIELD(DMACFG, TX_PBUF_CSUM_OFFLOAD, 11, 1) | ||
34 | + FIELD(DMACFG, TX_PBUF_SIZE, 10, 1) | ||
35 | + FIELD(DMACFG, RX_PBUF_SIZE, 8, 2) | ||
36 | + FIELD(DMACFG, ENDIAN_SWAP_PACKET, 7, 1) | ||
37 | + FIELD(DMACFG, ENDIAN_SWAP_MGNT, 6, 1) | ||
38 | + FIELD(DMACFG, HDR_DATA_SPLIT_EN, 5, 1) | ||
39 | + FIELD(DMACFG, AMBA_BURST_LEN , 0, 5) | ||
40 | +#define GEM_DMACFG_RBUFSZ_MUL 64 /* DMA RX Buffer Size multiplier */ | ||
41 | + | ||
42 | REG32(TXSTATUS, 0x14) /* TX Status reg */ | ||
43 | REG32(RXQBASE, 0x18) /* RX Q Base address reg */ | ||
44 | REG32(TXQBASE, 0x1c) /* TX Q Base address reg */ | ||
45 | @@ -XXX,XX +XXX,XX @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) | ||
46 | FIELD(TYPE2_COMPARE_0_WORD_1, COMPARE_VLAN_ID, 10, 1) | ||
47 | |||
48 | /*****************************************/ | ||
49 | -#define GEM_DMACFG_ADDR_64B (1U << 30) | ||
50 | -#define GEM_DMACFG_TX_BD_EXT (1U << 29) | ||
51 | -#define GEM_DMACFG_RX_BD_EXT (1U << 28) | ||
52 | -#define GEM_DMACFG_RBUFSZ_M 0x00FF0000 /* DMA RX Buffer Size mask */ | ||
53 | -#define GEM_DMACFG_RBUFSZ_S 16 /* DMA RX Buffer Size shift */ | ||
54 | -#define GEM_DMACFG_RBUFSZ_MUL 64 /* DMA RX Buffer Size multiplier */ | ||
55 | -#define GEM_DMACFG_TXCSUM_OFFL 0x00000800 /* Transmit checksum offload */ | ||
56 | |||
57 | #define GEM_TXSTATUS_TXCMPL 0x00000020 /* Transmit Complete */ | ||
58 | #define GEM_TXSTATUS_USED 0x00000001 /* sw owned descriptor encountered */ | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t tx_desc_get_buffer(CadenceGEMState *s, uint32_t *desc) | ||
32 | { | 60 | { |
33 | const size_t cpu_count = ARRAY_SIZE(arm_cpus); | 61 | uint64_t ret = desc[0]; |
34 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_register_types(void) | 62 | |
35 | if (cpu_count) { | 63 | - if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { |
36 | size_t i; | 64 | + if (FIELD_EX32(s->regs[R_DMACFG], DMACFG, DMA_ADDR_BUS_WIDTH)) { |
37 | 65 | ret |= (uint64_t)desc[2] << 32; | |
38 | - type_register_static(&idau_interface_type_info); | 66 | } |
39 | for (i = 0; i < cpu_count; ++i) { | 67 | return ret; |
40 | arm_cpu_register(&arm_cpus[i]); | 68 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t rx_desc_get_buffer(CadenceGEMState *s, uint32_t *desc) |
41 | } | 69 | { |
42 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 70 | uint64_t ret = desc[0] & ~0x3UL; |
43 | index XXXXXXX..XXXXXXX 100644 | 71 | |
44 | --- a/target/arm/cpu_tcg.c | 72 | - if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { |
45 | +++ b/target/arm/cpu_tcg.c | 73 | + if (FIELD_EX32(s->regs[R_DMACFG], DMACFG, DMA_ADDR_BUS_WIDTH)) { |
46 | @@ -XXX,XX +XXX,XX @@ | 74 | ret |= (uint64_t)desc[2] << 32; |
47 | #include "hw/core/tcg-cpu-ops.h" | 75 | } |
48 | #endif /* CONFIG_TCG */ | 76 | return ret; |
49 | #include "internals.h" | 77 | @@ -XXX,XX +XXX,XX @@ static inline int gem_get_desc_len(CadenceGEMState *s, bool rx_n_tx) |
50 | +#include "target/arm/idau.h" | 78 | { |
51 | 79 | int ret = 2; | |
52 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | 80 | |
53 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | 81 | - if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { |
54 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | 82 | + if (FIELD_EX32(s->regs[R_DMACFG], DMACFG, DMA_ADDR_BUS_WIDTH)) { |
55 | { .name = "pxa270-c5", .initfn = pxa270c5_initfn }, | 83 | ret += 2; |
56 | }; | 84 | } |
57 | 85 | - if (s->regs[R_DMACFG] & (rx_n_tx ? GEM_DMACFG_RX_BD_EXT | |
58 | +static const TypeInfo idau_interface_type_info = { | 86 | - : GEM_DMACFG_TX_BD_EXT)) { |
59 | + .name = TYPE_IDAU_INTERFACE, | 87 | + if (s->regs[R_DMACFG] & (rx_n_tx ? R_DMACFG_RX_BD_EXT_MODE_EN_MASK |
60 | + .parent = TYPE_INTERFACE, | 88 | + : R_DMACFG_TX_BD_EXT_MODE_EN_MASK)) { |
61 | + .class_size = sizeof(IDAUInterfaceClass), | 89 | ret += 2; |
62 | +}; | 90 | } |
91 | |||
92 | @@ -XXX,XX +XXX,XX @@ static hwaddr gem_get_desc_addr(CadenceGEMState *s, bool tx, int q) | ||
93 | { | ||
94 | hwaddr desc_addr = 0; | ||
95 | |||
96 | - if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
97 | + if (FIELD_EX32(s->regs[R_DMACFG], DMACFG, DMA_ADDR_BUS_WIDTH)) { | ||
98 | desc_addr = s->regs[tx ? R_TBQPH : R_RBQPH]; | ||
99 | } | ||
100 | desc_addr <<= 32; | ||
101 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
102 | /* The configure size of each receive buffer. Determines how many | ||
103 | * buffers needed to hold this packet. | ||
104 | */ | ||
105 | - rxbufsize = ((s->regs[R_DMACFG] & GEM_DMACFG_RBUFSZ_M) >> | ||
106 | - GEM_DMACFG_RBUFSZ_S) * GEM_DMACFG_RBUFSZ_MUL; | ||
107 | + rxbufsize = FIELD_EX32(s->regs[R_DMACFG], DMACFG, RX_BUF_SIZE); | ||
108 | + rxbufsize *= GEM_DMACFG_RBUFSZ_MUL; | ||
63 | + | 109 | + |
64 | static void arm_tcg_cpu_register_types(void) | 110 | bytes_to_copy = size; |
65 | { | 111 | |
66 | size_t i; | 112 | /* Hardware allows a zero value here but warns against it. To avoid QEMU |
67 | 113 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | |
68 | + type_register_static(&idau_interface_type_info); | 114 | gem_update_int_status(s); |
69 | for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) { | 115 | |
70 | arm_cpu_register(&arm_tcg_cpus[i]); | 116 | /* Is checksum offload enabled? */ |
71 | } | 117 | - if (s->regs[R_DMACFG] & GEM_DMACFG_TXCSUM_OFFL) { |
118 | + if (FIELD_EX32(s->regs[R_DMACFG], DMACFG, TX_PBUF_CSUM_OFFLOAD)) { | ||
119 | net_checksum_calculate(s->tx_packet, total_bytes, CSUM_ALL); | ||
120 | } | ||
121 | |||
122 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
123 | |||
124 | /* read next descriptor */ | ||
125 | if (tx_desc_get_wrap(desc)) { | ||
126 | - if (s->regs[R_DMACFG] & GEM_DMACFG_ADDR_64B) { | ||
127 | + if (FIELD_EX32(s->regs[R_DMACFG], DMACFG, DMA_ADDR_BUS_WIDTH)) { | ||
128 | packet_desc_addr = s->regs[R_TBQPH]; | ||
129 | packet_desc_addr <<= 32; | ||
130 | } else { | ||
72 | -- | 131 | -- |
73 | 2.20.1 | 132 | 2.34.1 |
74 | |||
75 | diff view generated by jsdifflib |
1 | From: Rebecca Cran <rebecca@nuviainc.com> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Set ID_AA64PFR1_EL1.SSBS to 2 and ID_PFR2.SSBS to 1. | 3 | Use de FIELD macro to describe the TXSTATUS and RXSTATUS register |
4 | fields. | ||
4 | 5 | ||
5 | Signed-off-by: Rebecca Cran <rebecca@nuviainc.com> | 6 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: sai.pavan.boddu@amd.com |
7 | Message-id: 20210216224543.16142-3-rebecca@nuviainc.com | 8 | Message-id: 20231017194422.4124691-7-luc.michel@amd.com |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/cpu64.c | 5 +++++ | 11 | hw/net/cadence_gem.c | 34 +++++++++++++++++++++++++--------- |
11 | 1 file changed, 5 insertions(+) | 12 | 1 file changed, 25 insertions(+), 9 deletions(-) |
12 | 13 | ||
13 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 14 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu64.c | 16 | --- a/hw/net/cadence_gem.c |
16 | +++ b/target/arm/cpu64.c | 17 | +++ b/hw/net/cadence_gem.c |
17 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ REG32(DMACFG, 0x10) /* DMA Control reg */ |
18 | 19 | #define GEM_DMACFG_RBUFSZ_MUL 64 /* DMA RX Buffer Size multiplier */ | |
19 | t = cpu->isar.id_aa64pfr1; | 20 | |
20 | t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); | 21 | REG32(TXSTATUS, 0x14) /* TX Status reg */ |
21 | + t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); | 22 | + FIELD(TXSTATUS, TX_USED_BIT_READ_MIDFRAME, 12, 1) |
22 | /* | 23 | + FIELD(TXSTATUS, TX_FRAME_TOO_LARGE, 11, 1) |
23 | * Begin with full support for MTE. This will be downgraded to MTE=0 | 24 | + FIELD(TXSTATUS, TX_DMA_LOCKUP, 10, 1) |
24 | * during realize if the board provides no tag memory, much like | 25 | + FIELD(TXSTATUS, TX_MAC_LOCKUP, 9, 1) |
25 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 26 | + FIELD(TXSTATUS, RESP_NOT_OK, 8, 1) |
26 | u = FIELD_DP32(u, ID_PFR0, DIT, 1); | 27 | + FIELD(TXSTATUS, LATE_COLLISION, 7, 1) |
27 | cpu->isar.id_pfr0 = u; | 28 | + FIELD(TXSTATUS, TRANSMIT_UNDER_RUN, 6, 1) |
28 | 29 | + FIELD(TXSTATUS, TRANSMIT_COMPLETE, 5, 1) | |
29 | + u = cpu->isar.id_pfr2; | 30 | + FIELD(TXSTATUS, AMBA_ERROR, 4, 1) |
30 | + u = FIELD_DP32(u, ID_PFR2, SSBS, 1); | 31 | + FIELD(TXSTATUS, TRANSMIT_GO, 3, 1) |
31 | + cpu->isar.id_pfr2 = u; | 32 | + FIELD(TXSTATUS, RETRY_LIMIT, 2, 1) |
33 | + FIELD(TXSTATUS, COLLISION, 1, 1) | ||
34 | + FIELD(TXSTATUS, USED_BIT_READ, 0, 1) | ||
32 | + | 35 | + |
33 | u = cpu->isar.id_mmfr3; | 36 | REG32(RXQBASE, 0x18) /* RX Q Base address reg */ |
34 | u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | 37 | REG32(TXQBASE, 0x1c) /* TX Q Base address reg */ |
35 | cpu->isar.id_mmfr3 = u; | 38 | REG32(RXSTATUS, 0x20) /* RX Status reg */ |
39 | + FIELD(RXSTATUS, RX_DMA_LOCKUP, 5, 1) | ||
40 | + FIELD(RXSTATUS, RX_MAC_LOCKUP, 4, 1) | ||
41 | + FIELD(RXSTATUS, RESP_NOT_OK, 3, 1) | ||
42 | + FIELD(RXSTATUS, RECEIVE_OVERRUN, 2, 1) | ||
43 | + FIELD(RXSTATUS, FRAME_RECEIVED, 1, 1) | ||
44 | + FIELD(RXSTATUS, BUF_NOT_AVAILABLE, 0, 1) | ||
45 | + | ||
46 | REG32(ISR, 0x24) /* Interrupt Status reg */ | ||
47 | REG32(IER, 0x28) /* Interrupt Enable reg */ | ||
48 | REG32(IDR, 0x2c) /* Interrupt Disable reg */ | ||
49 | @@ -XXX,XX +XXX,XX @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) | ||
50 | |||
51 | /*****************************************/ | ||
52 | |||
53 | -#define GEM_TXSTATUS_TXCMPL 0x00000020 /* Transmit Complete */ | ||
54 | -#define GEM_TXSTATUS_USED 0x00000001 /* sw owned descriptor encountered */ | ||
55 | - | ||
56 | -#define GEM_RXSTATUS_FRMRCVD 0x00000002 /* Frame received */ | ||
57 | -#define GEM_RXSTATUS_NOBUF 0x00000001 /* Buffer unavailable */ | ||
58 | |||
59 | /* GEM_ISR GEM_IER GEM_IDR GEM_IMR */ | ||
60 | #define GEM_INT_TXCMPL 0x00000080 /* Transmit Complete */ | ||
61 | @@ -XXX,XX +XXX,XX @@ static void gem_get_rx_desc(CadenceGEMState *s, int q) | ||
62 | /* Descriptor owned by software ? */ | ||
63 | if (rx_desc_get_ownership(s->rx_desc[q]) == 1) { | ||
64 | DB_PRINT("descriptor 0x%" HWADDR_PRIx " owned by sw.\n", desc_addr); | ||
65 | - s->regs[R_RXSTATUS] |= GEM_RXSTATUS_NOBUF; | ||
66 | + s->regs[R_RXSTATUS] |= R_RXSTATUS_BUF_NOT_AVAILABLE_MASK; | ||
67 | gem_set_isr(s, q, GEM_INT_RXUSED); | ||
68 | /* Handle interrupt consequences */ | ||
69 | gem_update_int_status(s); | ||
70 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
71 | /* Count it */ | ||
72 | gem_receive_updatestats(s, buf, size); | ||
73 | |||
74 | - s->regs[R_RXSTATUS] |= GEM_RXSTATUS_FRMRCVD; | ||
75 | + s->regs[R_RXSTATUS] |= R_RXSTATUS_FRAME_RECEIVED_MASK; | ||
76 | gem_set_isr(s, q, GEM_INT_RXCMPL); | ||
77 | |||
78 | /* Handle interrupt consequences */ | ||
79 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
80 | } | ||
81 | DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr[q]); | ||
82 | |||
83 | - s->regs[R_TXSTATUS] |= GEM_TXSTATUS_TXCMPL; | ||
84 | + s->regs[R_TXSTATUS] |= R_TXSTATUS_TRANSMIT_COMPLETE_MASK; | ||
85 | gem_set_isr(s, q, GEM_INT_TXCMPL); | ||
86 | |||
87 | /* Handle interrupt consequences */ | ||
88 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) | ||
89 | } | ||
90 | |||
91 | if (tx_desc_get_used(desc)) { | ||
92 | - s->regs[R_TXSTATUS] |= GEM_TXSTATUS_USED; | ||
93 | + s->regs[R_TXSTATUS] |= R_TXSTATUS_USED_BIT_READ_MASK; | ||
94 | /* IRQ TXUSED is defined only for queue 0 */ | ||
95 | if (q == 0) { | ||
96 | gem_set_isr(s, 0, GEM_INT_TXUSED); | ||
36 | -- | 97 | -- |
37 | 2.20.1 | 98 | 2.34.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Doug Evans <dje@google.com> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | This is a 10/100 ethernet device that has several features. | 3 | Use de FIELD macro to describe the IRQ related register fields. |
4 | Only the ones needed by the Linux driver have been implemented. | ||
5 | See npcm7xx_emc.c for a list of unimplemented features. | ||
6 | 4 | ||
7 | Reviewed-by: Hao Wu <wuhaotsh@google.com> | 5 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
8 | Reviewed-by: Avi Fishman <avi.fishman@nuvoton.com> | 6 | Reviewed-by: sai.pavan.boddu@amd.com |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20231017194422.4124691-8-luc.michel@amd.com |
10 | Signed-off-by: Doug Evans <dje@google.com> | ||
11 | Message-id: 20210218212453.831406-3-dje@google.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | docs/system/arm/nuvoton.rst | 3 ++- | 10 | hw/net/cadence_gem.c | 51 +++++++++++++++++++++++++++++++++----------- |
15 | include/hw/arm/npcm7xx.h | 2 ++ | 11 | 1 file changed, 39 insertions(+), 12 deletions(-) |
16 | hw/arm/npcm7xx.c | 50 +++++++++++++++++++++++++++++++++++-- | ||
17 | 3 files changed, 52 insertions(+), 3 deletions(-) | ||
18 | 12 | ||
19 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/docs/system/arm/nuvoton.rst | 15 | --- a/hw/net/cadence_gem.c |
22 | +++ b/docs/system/arm/nuvoton.rst | 16 | +++ b/hw/net/cadence_gem.c |
23 | @@ -XXX,XX +XXX,XX @@ Supported devices | 17 | @@ -XXX,XX +XXX,XX @@ REG32(RXSTATUS, 0x20) /* RX Status reg */ |
24 | * Analog to Digital Converter (ADC) | 18 | FIELD(RXSTATUS, BUF_NOT_AVAILABLE, 0, 1) |
25 | * Pulse Width Modulation (PWM) | 19 | |
26 | * SMBus controller (SMBF) | 20 | REG32(ISR, 0x24) /* Interrupt Status reg */ |
27 | + * Ethernet controller (EMC) | 21 | + FIELD(ISR, TX_LOCKUP, 31, 1) |
28 | 22 | + FIELD(ISR, RX_LOCKUP, 30, 1) | |
29 | Missing devices | 23 | + FIELD(ISR, TSU_TIMER, 29, 1) |
30 | --------------- | 24 | + FIELD(ISR, WOL, 28, 1) |
31 | @@ -XXX,XX +XXX,XX @@ Missing devices | 25 | + FIELD(ISR, RECV_LPI, 27, 1) |
32 | * Shared memory (SHM) | 26 | + FIELD(ISR, TSU_SEC_INCR, 26, 1) |
33 | * eSPI slave interface | 27 | + FIELD(ISR, PTP_PDELAY_RESP_XMIT, 25, 1) |
34 | 28 | + FIELD(ISR, PTP_PDELAY_REQ_XMIT, 24, 1) | |
35 | - * Ethernet controllers (GMAC and EMC) | 29 | + FIELD(ISR, PTP_PDELAY_RESP_RECV, 23, 1) |
36 | + * Ethernet controller (GMAC) | 30 | + FIELD(ISR, PTP_PDELAY_REQ_RECV, 22, 1) |
37 | * USB device (USBD) | 31 | + FIELD(ISR, PTP_SYNC_XMIT, 21, 1) |
38 | * Peripheral SPI controller (PSPI) | 32 | + FIELD(ISR, PTP_DELAY_REQ_XMIT, 20, 1) |
39 | * SD/MMC host | 33 | + FIELD(ISR, PTP_SYNC_RECV, 19, 1) |
40 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | 34 | + FIELD(ISR, PTP_DELAY_REQ_RECV, 18, 1) |
41 | index XXXXXXX..XXXXXXX 100644 | 35 | + FIELD(ISR, PCS_LP_PAGE_RECV, 17, 1) |
42 | --- a/include/hw/arm/npcm7xx.h | 36 | + FIELD(ISR, PCS_AN_COMPLETE, 16, 1) |
43 | +++ b/include/hw/arm/npcm7xx.h | 37 | + FIELD(ISR, EXT_IRQ, 15, 1) |
44 | @@ -XXX,XX +XXX,XX @@ | 38 | + FIELD(ISR, PAUSE_FRAME_XMIT, 14, 1) |
45 | #include "hw/misc/npcm7xx_gcr.h" | 39 | + FIELD(ISR, PAUSE_TIME_ELAPSED, 13, 1) |
46 | #include "hw/misc/npcm7xx_pwm.h" | 40 | + FIELD(ISR, PAUSE_FRAME_RECV, 12, 1) |
47 | #include "hw/misc/npcm7xx_rng.h" | 41 | + FIELD(ISR, RESP_NOT_OK, 11, 1) |
48 | +#include "hw/net/npcm7xx_emc.h" | 42 | + FIELD(ISR, RECV_OVERRUN, 10, 1) |
49 | #include "hw/nvram/npcm7xx_otp.h" | 43 | + FIELD(ISR, LINK_CHANGE, 9, 1) |
50 | #include "hw/timer/npcm7xx_timer.h" | 44 | + FIELD(ISR, USXGMII_INT, 8, 1) |
51 | #include "hw/ssi/npcm7xx_fiu.h" | 45 | + FIELD(ISR, XMIT_COMPLETE, 7, 1) |
52 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState { | 46 | + FIELD(ISR, AMBA_ERROR, 6, 1) |
53 | EHCISysBusState ehci; | 47 | + FIELD(ISR, RETRY_EXCEEDED, 5, 1) |
54 | OHCISysBusState ohci; | 48 | + FIELD(ISR, XMIT_UNDER_RUN, 4, 1) |
55 | NPCM7xxFIUState fiu[2]; | 49 | + FIELD(ISR, TX_USED, 3, 1) |
56 | + NPCM7xxEMCState emc[2]; | 50 | + FIELD(ISR, RX_USED, 2, 1) |
57 | } NPCM7xxState; | 51 | + FIELD(ISR, RECV_COMPLETE, 1, 1) |
58 | 52 | + FIELD(ISR, MGNT_FRAME_SENT, 0, 1) | |
59 | #define TYPE_NPCM7XX "npcm7xx" | 53 | REG32(IER, 0x28) /* Interrupt Enable reg */ |
60 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | 54 | REG32(IDR, 0x2c) /* Interrupt Disable reg */ |
61 | index XXXXXXX..XXXXXXX 100644 | 55 | REG32(IMR, 0x30) /* Interrupt Mask reg */ |
62 | --- a/hw/arm/npcm7xx.c | ||
63 | +++ b/hw/arm/npcm7xx.c | ||
64 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
65 | NPCM7XX_UART1_IRQ, | ||
66 | NPCM7XX_UART2_IRQ, | ||
67 | NPCM7XX_UART3_IRQ, | ||
68 | + NPCM7XX_EMC1RX_IRQ = 15, | ||
69 | + NPCM7XX_EMC1TX_IRQ, | ||
70 | NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */ | ||
71 | NPCM7XX_TIMER1_IRQ, | ||
72 | NPCM7XX_TIMER2_IRQ, | ||
73 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
74 | NPCM7XX_SMBUS15_IRQ, | ||
75 | NPCM7XX_PWM0_IRQ = 93, /* PWM module 0 */ | ||
76 | NPCM7XX_PWM1_IRQ, /* PWM module 1 */ | ||
77 | + NPCM7XX_EMC2RX_IRQ = 114, | ||
78 | + NPCM7XX_EMC2TX_IRQ, | ||
79 | NPCM7XX_GPIO0_IRQ = 116, | ||
80 | NPCM7XX_GPIO1_IRQ, | ||
81 | NPCM7XX_GPIO2_IRQ, | ||
82 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_smbus_addr[] = { | ||
83 | 0xf008f000, | ||
84 | }; | ||
85 | |||
86 | +/* Register base address for each EMC Module */ | ||
87 | +static const hwaddr npcm7xx_emc_addr[] = { | ||
88 | + 0xf0825000, | ||
89 | + 0xf0826000, | ||
90 | +}; | ||
91 | + | 56 | + |
92 | static const struct { | 57 | REG32(PHYMNTNC, 0x34) /* Phy Maintenance reg */ |
93 | hwaddr regs_addr; | 58 | REG32(RXPAUSE, 0x38) /* RX Pause Time reg */ |
94 | uint32_t unconnected_pins; | 59 | REG32(TXPAUSE, 0x3c) /* TX Pause Time reg */ |
95 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj) | 60 | @@ -XXX,XX +XXX,XX @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) |
96 | for (i = 0; i < ARRAY_SIZE(s->pwm); i++) { | 61 | /*****************************************/ |
97 | object_initialize_child(obj, "pwm[*]", &s->pwm[i], TYPE_NPCM7XX_PWM); | 62 | |
63 | |||
64 | -/* GEM_ISR GEM_IER GEM_IDR GEM_IMR */ | ||
65 | -#define GEM_INT_TXCMPL 0x00000080 /* Transmit Complete */ | ||
66 | -#define GEM_INT_AMBA_ERR 0x00000040 | ||
67 | -#define GEM_INT_TXUSED 0x00000008 | ||
68 | -#define GEM_INT_RXUSED 0x00000004 | ||
69 | -#define GEM_INT_RXCMPL 0x00000002 | ||
70 | |||
71 | #define GEM_PHYMNTNC_OP_R 0x20000000 /* read operation */ | ||
72 | #define GEM_PHYMNTNC_OP_W 0x10000000 /* write operation */ | ||
73 | @@ -XXX,XX +XXX,XX @@ static void gem_get_rx_desc(CadenceGEMState *s, int q) | ||
74 | if (rx_desc_get_ownership(s->rx_desc[q]) == 1) { | ||
75 | DB_PRINT("descriptor 0x%" HWADDR_PRIx " owned by sw.\n", desc_addr); | ||
76 | s->regs[R_RXSTATUS] |= R_RXSTATUS_BUF_NOT_AVAILABLE_MASK; | ||
77 | - gem_set_isr(s, q, GEM_INT_RXUSED); | ||
78 | + gem_set_isr(s, q, R_ISR_RX_USED_MASK); | ||
79 | /* Handle interrupt consequences */ | ||
80 | gem_update_int_status(s); | ||
98 | } | 81 | } |
99 | + | 82 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) |
100 | + for (i = 0; i < ARRAY_SIZE(s->emc); i++) { | 83 | |
101 | + object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); | 84 | if (size > gem_get_max_buf_len(s, false)) { |
102 | + } | 85 | qemu_log_mask(LOG_GUEST_ERROR, "rx frame too long\n"); |
103 | } | 86 | - gem_set_isr(s, q, GEM_INT_AMBA_ERR); |
104 | 87 | + gem_set_isr(s, q, R_ISR_AMBA_ERROR_MASK); | |
105 | static void npcm7xx_realize(DeviceState *dev, Error **errp) | 88 | return -1; |
106 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | ||
107 | sysbus_connect_irq(sbd, i, npcm7xx_irq(s, NPCM7XX_PWM0_IRQ + i)); | ||
108 | } | 89 | } |
109 | 90 | ||
110 | + /* | 91 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) |
111 | + * EMC Modules. Cannot fail. | 92 | gem_receive_updatestats(s, buf, size); |
112 | + * The mapping of the device to its netdev backend works as follows: | 93 | |
113 | + * emc[i] = nd_table[i] | 94 | s->regs[R_RXSTATUS] |= R_RXSTATUS_FRAME_RECEIVED_MASK; |
114 | + * This works around the inability to specify the netdev property for the | 95 | - gem_set_isr(s, q, GEM_INT_RXCMPL); |
115 | + * emc device: it's not pluggable and thus the -device option can't be | 96 | + gem_set_isr(s, q, R_ISR_RECV_COMPLETE_MASK); |
116 | + * used. | 97 | |
117 | + */ | 98 | /* Handle interrupt consequences */ |
118 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_emc_addr) != ARRAY_SIZE(s->emc)); | 99 | gem_update_int_status(s); |
119 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->emc) != 2); | 100 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
120 | + for (i = 0; i < ARRAY_SIZE(s->emc); i++) { | 101 | HWADDR_PRIx " too large: size 0x%x space 0x%zx\n", |
121 | + s->emc[i].emc_num = i; | 102 | packet_desc_addr, tx_desc_get_length(desc), |
122 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->emc[i]); | 103 | gem_get_max_buf_len(s, true) - (p - s->tx_packet)); |
123 | + if (nd_table[i].used) { | 104 | - gem_set_isr(s, q, GEM_INT_AMBA_ERR); |
124 | + qemu_check_nic_model(&nd_table[i], TYPE_NPCM7XX_EMC); | 105 | + gem_set_isr(s, q, R_ISR_AMBA_ERROR_MASK); |
125 | + qdev_set_nic_properties(DEVICE(sbd), &nd_table[i]); | 106 | break; |
126 | + } | 107 | } |
127 | + /* | 108 | |
128 | + * The device exists regardless of whether it's connected to a QEMU | 109 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
129 | + * netdev backend. So always instantiate it even if there is no | 110 | DB_PRINT("TX descriptor next: 0x%08x\n", s->tx_desc_addr[q]); |
130 | + * backend. | 111 | |
131 | + */ | 112 | s->regs[R_TXSTATUS] |= R_TXSTATUS_TRANSMIT_COMPLETE_MASK; |
132 | + sysbus_realize(sbd, &error_abort); | 113 | - gem_set_isr(s, q, GEM_INT_TXCMPL); |
133 | + sysbus_mmio_map(sbd, 0, npcm7xx_emc_addr[i]); | 114 | + gem_set_isr(s, q, R_ISR_XMIT_COMPLETE_MASK); |
134 | + int tx_irq = i == 0 ? NPCM7XX_EMC1TX_IRQ : NPCM7XX_EMC2TX_IRQ; | 115 | |
135 | + int rx_irq = i == 0 ? NPCM7XX_EMC1RX_IRQ : NPCM7XX_EMC2RX_IRQ; | 116 | /* Handle interrupt consequences */ |
136 | + /* | 117 | gem_update_int_status(s); |
137 | + * N.B. The values for the second argument sysbus_connect_irq are | 118 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
138 | + * chosen to match the registration order in npcm7xx_emc_realize. | 119 | s->regs[R_TXSTATUS] |= R_TXSTATUS_USED_BIT_READ_MASK; |
139 | + */ | 120 | /* IRQ TXUSED is defined only for queue 0 */ |
140 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, tx_irq)); | 121 | if (q == 0) { |
141 | + sysbus_connect_irq(sbd, 1, npcm7xx_irq(s, rx_irq)); | 122 | - gem_set_isr(s, 0, GEM_INT_TXUSED); |
142 | + } | 123 | + gem_set_isr(s, 0, R_ISR_TX_USED_MASK); |
143 | + | 124 | } |
144 | /* | 125 | gem_update_int_status(s); |
145 | * Flash Interface Unit (FIU). Can fail if incorrect number of chip selects | 126 | } |
146 | * specified, but this is a programming error. | ||
147 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | ||
148 | create_unimplemented_device("npcm7xx.vcd", 0xf0810000, 64 * KiB); | ||
149 | create_unimplemented_device("npcm7xx.ece", 0xf0820000, 8 * KiB); | ||
150 | create_unimplemented_device("npcm7xx.vdma", 0xf0822000, 8 * KiB); | ||
151 | - create_unimplemented_device("npcm7xx.emc1", 0xf0825000, 4 * KiB); | ||
152 | - create_unimplemented_device("npcm7xx.emc2", 0xf0826000, 4 * KiB); | ||
153 | create_unimplemented_device("npcm7xx.usbd[0]", 0xf0830000, 4 * KiB); | ||
154 | create_unimplemented_device("npcm7xx.usbd[1]", 0xf0831000, 4 * KiB); | ||
155 | create_unimplemented_device("npcm7xx.usbd[2]", 0xf0832000, 4 * KiB); | ||
156 | -- | 127 | -- |
157 | 2.20.1 | 128 | 2.34.1 |
158 | |||
159 | diff view generated by jsdifflib |
1 | The AN524 has a different SYSCLK frequency from the AN505 and AN521; | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | make the SYSCLK frequency a field in the MPS2TZMachineClass rather | ||
3 | than a compile-time constant so we can support the AN524. | ||
4 | 2 | ||
3 | Use the FIELD macro to describe the DESCONF6 register fields. | ||
4 | |||
5 | Signed-off-by: Luc Michel <luc.michel@amd.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Message-id: 20231017194422.4124691-9-luc.michel@amd.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210215115138.20465-2-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | hw/arm/mps2-tz.c | 10 ++++++---- | 10 | hw/net/cadence_gem.c | 4 ++-- |
11 | 1 file changed, 6 insertions(+), 4 deletions(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/mps2-tz.c | 15 | --- a/hw/net/cadence_gem.c |
16 | +++ b/hw/arm/mps2-tz.c | 16 | +++ b/hw/net/cadence_gem.c |
17 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | 17 | @@ -XXX,XX +XXX,XX @@ REG32(DESCONF3, 0x288) |
18 | MachineClass parent; | 18 | REG32(DESCONF4, 0x28c) |
19 | MPS2TZFPGAType fpga_type; | 19 | REG32(DESCONF5, 0x290) |
20 | uint32_t scc_id; | 20 | REG32(DESCONF6, 0x294) |
21 | + uint32_t sysclk_frq; /* Main SYSCLK frequency in Hz */ | 21 | -#define GEM_DESCONF6_64B_MASK (1U << 23) |
22 | const char *armsse_type; | 22 | + FIELD(DESCONF6, DMA_ADDR_64B, 23, 1) |
23 | }; | 23 | REG32(DESCONF7, 0x298) |
24 | 24 | ||
25 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | 25 | REG32(INT_Q1_STATUS, 0x400) |
26 | 26 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | |
27 | OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | 27 | s->regs[R_DESCONF] = 0x02D00111; |
28 | 28 | s->regs[R_DESCONF2] = 0x2ab10000 | s->jumbo_max_len; | |
29 | -/* Main SYSCLK frequency in Hz */ | 29 | s->regs[R_DESCONF5] = 0x002f2045; |
30 | -#define SYSCLK_FRQ 20000000 | 30 | - s->regs[R_DESCONF6] = GEM_DESCONF6_64B_MASK; |
31 | /* Slow 32Khz S32KCLK frequency in Hz */ | 31 | + s->regs[R_DESCONF6] = R_DESCONF6_DMA_ADDR_64B_MASK; |
32 | #define S32KCLK_FRQ (32 * 1000) | 32 | s->regs[R_INT_Q1_MASK] = 0x00000CE6; |
33 | 33 | s->regs[R_JUMBO_MAX_LEN] = s->jumbo_max_len; | |
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | ||
35 | static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
36 | const char *name, hwaddr size) | ||
37 | { | ||
38 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
39 | CMSDKAPBUART *uart = opaque; | ||
40 | int i = uart - &mms->uart[0]; | ||
41 | int rxirqno = i * 2; | ||
42 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
43 | |||
44 | object_initialize_child(OBJECT(mms), name, uart, TYPE_CMSDK_APB_UART); | ||
45 | qdev_prop_set_chr(DEVICE(uart), "chardev", serial_hd(i)); | ||
46 | - qdev_prop_set_uint32(DEVICE(uart), "pclk-frq", SYSCLK_FRQ); | ||
47 | + qdev_prop_set_uint32(DEVICE(uart), "pclk-frq", mmc->sysclk_frq); | ||
48 | sysbus_realize(SYS_BUS_DEVICE(uart), &error_fatal); | ||
49 | s = SYS_BUS_DEVICE(uart); | ||
50 | sysbus_connect_irq(s, 0, get_sse_irq_in(mms, txirqno)); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
52 | |||
53 | /* These clocks don't need migration because they are fixed-frequency */ | ||
54 | mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
55 | - clock_set_hz(mms->sysclk, SYSCLK_FRQ); | ||
56 | + clock_set_hz(mms->sysclk, mmc->sysclk_frq); | ||
57 | mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); | ||
58 | clock_set_hz(mms->s32kclk, S32KCLK_FRQ); | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | ||
61 | mmc->fpga_type = FPGA_AN505; | ||
62 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | ||
63 | mmc->scc_id = 0x41045050; | ||
64 | + mmc->sysclk_frq = 20 * 1000 * 1000; /* 20MHz */ | ||
65 | mmc->armsse_type = TYPE_IOTKIT; | ||
66 | } | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
69 | mmc->fpga_type = FPGA_AN521; | ||
70 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | ||
71 | mmc->scc_id = 0x41045210; | ||
72 | + mmc->sysclk_frq = 20 * 1000 * 1000; /* 20MHz */ | ||
73 | mmc->armsse_type = TYPE_SSE200; | ||
74 | } | ||
75 | 34 | ||
76 | -- | 35 | -- |
77 | 2.20.1 | 36 | 2.34.1 |
78 | 37 | ||
79 | 38 | diff view generated by jsdifflib |
1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Let add 'max' cpu while work goes on adding newer CPU types than | 3 | Use the FIELD macro to describe the PHYMNTNC register fields. |
4 | Cortex-A72. This allows us to check SVE etc support. | ||
5 | 4 | ||
6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | 5 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
7 | Acked-by: Leif Lindholm <leif@nuviainc.com> | 6 | Reviewed-by: sai.pavan.boddu@amd.com |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20231017194422.4124691-10-luc.michel@amd.com |
9 | Message-id: 20210216150122.3830863-3-marcin.juszkiewicz@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | hw/arm/sbsa-ref.c | 1 + | 10 | hw/net/cadence_gem.c | 27 ++++++++++++++------------- |
13 | 1 file changed, 1 insertion(+) | 11 | 1 file changed, 14 insertions(+), 13 deletions(-) |
14 | 12 | ||
15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 13 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/sbsa-ref.c | 15 | --- a/hw/net/cadence_gem.c |
18 | +++ b/hw/arm/sbsa-ref.c | 16 | +++ b/hw/net/cadence_gem.c |
19 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | 17 | @@ -XXX,XX +XXX,XX @@ REG32(IDR, 0x2c) /* Interrupt Disable reg */ |
20 | static const char * const valid_cpus[] = { | 18 | REG32(IMR, 0x30) /* Interrupt Mask reg */ |
21 | ARM_CPU_TYPE_NAME("cortex-a57"), | 19 | |
22 | ARM_CPU_TYPE_NAME("cortex-a72"), | 20 | REG32(PHYMNTNC, 0x34) /* Phy Maintenance reg */ |
23 | + ARM_CPU_TYPE_NAME("max"), | 21 | + FIELD(PHYMNTNC, DATA, 0, 16) |
24 | }; | 22 | + FIELD(PHYMNTNC, REG_ADDR, 18, 5) |
25 | 23 | + FIELD(PHYMNTNC, PHY_ADDR, 23, 5) | |
26 | static bool cpu_type_valid(const char *cpu) | 24 | + FIELD(PHYMNTNC, OP, 28, 2) |
25 | + FIELD(PHYMNTNC, ST, 30, 2) | ||
26 | +#define MDIO_OP_READ 0x3 | ||
27 | +#define MDIO_OP_WRITE 0x2 | ||
28 | + | ||
29 | REG32(RXPAUSE, 0x38) /* RX Pause Time reg */ | ||
30 | REG32(TXPAUSE, 0x3c) /* TX Pause Time reg */ | ||
31 | REG32(TXPARTIALSF, 0x40) /* TX Partial Store and Forward */ | ||
32 | @@ -XXX,XX +XXX,XX @@ REG32(TYPE2_COMPARE_0_WORD_1, 0x704) | ||
33 | |||
34 | |||
35 | |||
36 | -#define GEM_PHYMNTNC_OP_R 0x20000000 /* read operation */ | ||
37 | -#define GEM_PHYMNTNC_OP_W 0x10000000 /* write operation */ | ||
38 | -#define GEM_PHYMNTNC_ADDR 0x0F800000 /* Address bits */ | ||
39 | -#define GEM_PHYMNTNC_ADDR_SHFT 23 | ||
40 | -#define GEM_PHYMNTNC_REG 0x007C0000 /* register bits */ | ||
41 | -#define GEM_PHYMNTNC_REG_SHIFT 18 | ||
42 | - | ||
43 | /* Marvell PHY definitions */ | ||
44 | #define BOARD_PHY_ADDRESS 0 /* PHY address we will emulate a device at */ | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) | ||
47 | /* The interrupts get updated at the end of the function. */ | ||
48 | break; | ||
49 | case R_PHYMNTNC: | ||
50 | - if (retval & GEM_PHYMNTNC_OP_R) { | ||
51 | + if (FIELD_EX32(retval, PHYMNTNC, OP) == MDIO_OP_READ) { | ||
52 | uint32_t phy_addr, reg_num; | ||
53 | |||
54 | - phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; | ||
55 | + phy_addr = FIELD_EX32(retval, PHYMNTNC, PHY_ADDR); | ||
56 | if (phy_addr == s->phy_addr) { | ||
57 | - reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; | ||
58 | + reg_num = FIELD_EX32(retval, PHYMNTNC, REG_ADDR); | ||
59 | retval &= 0xFFFF0000; | ||
60 | retval |= gem_phy_read(s, reg_num); | ||
61 | } else { | ||
62 | @@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, | ||
63 | s->sar_active[(offset - R_SPADDR1HI) / 2] = true; | ||
64 | break; | ||
65 | case R_PHYMNTNC: | ||
66 | - if (val & GEM_PHYMNTNC_OP_W) { | ||
67 | + if (FIELD_EX32(val, PHYMNTNC, OP) == MDIO_OP_WRITE) { | ||
68 | uint32_t phy_addr, reg_num; | ||
69 | |||
70 | - phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; | ||
71 | + phy_addr = FIELD_EX32(val, PHYMNTNC, PHY_ADDR); | ||
72 | if (phy_addr == s->phy_addr) { | ||
73 | - reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; | ||
74 | + reg_num = FIELD_EX32(val, PHYMNTNC, REG_ADDR); | ||
75 | gem_phy_write(s, reg_num, val); | ||
76 | } | ||
77 | } | ||
27 | -- | 78 | -- |
28 | 2.20.1 | 79 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | The AN505 and AN521 have the same layout of RAM; the AN524 does not. | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | Replace the current hard-coding of where the RAM is and which parts | ||
3 | of it are behind which MPCs with a data-driven approach. | ||
4 | 2 | ||
3 | The MDIO access is done only on a write to the PHYMNTNC register. A | ||
4 | subsequent read is used to retrieve the result but does not trigger an | ||
5 | MDIO access by itself. | ||
6 | |||
7 | Refactor the PHY access logic to perform all accesses (MDIO reads and | ||
8 | writes) at PHYMNTNC write time. | ||
9 | |||
10 | Signed-off-by: Luc Michel <luc.michel@amd.com> | ||
11 | Reviewed-by: sai.pavan.boddu@amd.com | ||
12 | Message-id: 20231017194422.4124691-11-luc.michel@amd.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210215115138.20465-17-peter.maydell@linaro.org | ||
8 | --- | 14 | --- |
9 | hw/arm/mps2-tz.c | 175 +++++++++++++++++++++++++++++++++++++---------- | 15 | hw/net/cadence_gem.c | 56 ++++++++++++++++++++++++++------------------ |
10 | 1 file changed, 138 insertions(+), 37 deletions(-) | 16 | 1 file changed, 33 insertions(+), 23 deletions(-) |
11 | 17 | ||
12 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 18 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
13 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/mps2-tz.c | 20 | --- a/hw/net/cadence_gem.c |
15 | +++ b/hw/arm/mps2-tz.c | 21 | +++ b/hw/net/cadence_gem.c |
16 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ static void gem_phy_write(CadenceGEMState *s, unsigned reg_num, uint16_t val) |
17 | #include "qom/object.h" | 23 | s->phy_regs[reg_num] = val; |
18 | 24 | } | |
19 | #define MPS2TZ_NUMIRQ_MAX 92 | 25 | |
20 | +#define MPS2TZ_RAM_MAX 4 | 26 | +static void gem_handle_phy_access(CadenceGEMState *s) |
21 | 27 | +{ | |
22 | typedef enum MPS2TZFPGAType { | 28 | + uint32_t val = s->regs[R_PHYMNTNC]; |
23 | FPGA_AN505, | 29 | + uint32_t phy_addr, reg_num; |
24 | FPGA_AN521, | ||
25 | } MPS2TZFPGAType; | ||
26 | |||
27 | +/* | ||
28 | + * Define the layout of RAM in a board, including which parts are | ||
29 | + * behind which MPCs. | ||
30 | + * mrindex specifies the index into mms->ram[] to use for the backing RAM; | ||
31 | + * -1 means "use the system RAM". | ||
32 | + */ | ||
33 | +typedef struct RAMInfo { | ||
34 | + const char *name; | ||
35 | + uint32_t base; | ||
36 | + uint32_t size; | ||
37 | + int mpc; /* MPC number, -1 for "not behind an MPC" */ | ||
38 | + int mrindex; | ||
39 | + int flags; | ||
40 | +} RAMInfo; | ||
41 | + | 30 | + |
42 | +/* | 31 | + phy_addr = FIELD_EX32(val, PHYMNTNC, PHY_ADDR); |
43 | + * Flag values: | ||
44 | + * IS_ALIAS: this RAM area is an alias to the upstream end of the | ||
45 | + * MPC specified by its .mpc value | ||
46 | + */ | ||
47 | +#define IS_ALIAS 1 | ||
48 | + | 32 | + |
49 | struct MPS2TZMachineClass { | 33 | + if (phy_addr != s->phy_addr) { |
50 | MachineClass parent; | 34 | + /* no phy at this address */ |
51 | MPS2TZFPGAType fpga_type; | 35 | + if (FIELD_EX32(val, PHYMNTNC, OP) == MDIO_OP_READ) { |
52 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | 36 | + s->regs[R_PHYMNTNC] = FIELD_DP32(val, PHYMNTNC, DATA, 0xffff); |
53 | uint32_t fpgaio_num_leds; /* Number of LEDs in FPGAIO LED0 register */ | ||
54 | bool fpgaio_has_switches; /* Does FPGAIO have SWITCH register? */ | ||
55 | int numirq; /* Number of external interrupts */ | ||
56 | + const RAMInfo *raminfo; | ||
57 | const char *armsse_type; | ||
58 | }; | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | ||
61 | MachineState parent; | ||
62 | |||
63 | ARMSSE iotkit; | ||
64 | - MemoryRegion ssram[3]; | ||
65 | - MemoryRegion ssram1_m; | ||
66 | + MemoryRegion ram[MPS2TZ_RAM_MAX]; | ||
67 | MPS2SCC scc; | ||
68 | MPS2FPGAIO fpgaio; | ||
69 | TZPPC ppc[5]; | ||
70 | - TZMPC ssram_mpc[3]; | ||
71 | + TZMPC mpc[3]; | ||
72 | PL022State spi[5]; | ||
73 | ArmSbconI2CState i2c[4]; | ||
74 | UnimplementedDeviceState i2s_audio; | ||
75 | @@ -XXX,XX +XXX,XX @@ static const uint32_t an505_oscclk[] = { | ||
76 | 25000000, | ||
77 | }; | ||
78 | |||
79 | +static const RAMInfo an505_raminfo[] = { { | ||
80 | + .name = "ssram-0", | ||
81 | + .base = 0x00000000, | ||
82 | + .size = 0x00400000, | ||
83 | + .mpc = 0, | ||
84 | + .mrindex = 0, | ||
85 | + }, { | ||
86 | + .name = "ssram-1", | ||
87 | + .base = 0x28000000, | ||
88 | + .size = 0x00200000, | ||
89 | + .mpc = 1, | ||
90 | + .mrindex = 1, | ||
91 | + }, { | ||
92 | + .name = "ssram-2", | ||
93 | + .base = 0x28200000, | ||
94 | + .size = 0x00200000, | ||
95 | + .mpc = 2, | ||
96 | + .mrindex = 2, | ||
97 | + }, { | ||
98 | + .name = "ssram-0-alias", | ||
99 | + .base = 0x00400000, | ||
100 | + .size = 0x00400000, | ||
101 | + .mpc = 0, | ||
102 | + .mrindex = 3, | ||
103 | + .flags = IS_ALIAS, | ||
104 | + }, { | ||
105 | + /* Use the largest bit of contiguous RAM as our "system memory" */ | ||
106 | + .name = "mps.ram", | ||
107 | + .base = 0x80000000, | ||
108 | + .size = 16 * MiB, | ||
109 | + .mpc = -1, | ||
110 | + .mrindex = -1, | ||
111 | + }, { | ||
112 | + .name = NULL, | ||
113 | + }, | ||
114 | +}; | ||
115 | + | ||
116 | +static const RAMInfo *find_raminfo_for_mpc(MPS2TZMachineState *mms, int mpc) | ||
117 | +{ | ||
118 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
119 | + const RAMInfo *p; | ||
120 | + | ||
121 | + for (p = mmc->raminfo; p->name; p++) { | ||
122 | + if (p->mpc == mpc && !(p->flags & IS_ALIAS)) { | ||
123 | + return p; | ||
124 | + } | 37 | + } |
125 | + } | 38 | + return; |
126 | + /* if raminfo array doesn't have an entry for each MPC this is a bug */ | ||
127 | + g_assert_not_reached(); | ||
128 | +} | ||
129 | + | ||
130 | +static MemoryRegion *mr_for_raminfo(MPS2TZMachineState *mms, | ||
131 | + const RAMInfo *raminfo) | ||
132 | +{ | ||
133 | + /* Return an initialized MemoryRegion for the RAMInfo. */ | ||
134 | + MemoryRegion *ram; | ||
135 | + | ||
136 | + if (raminfo->mrindex < 0) { | ||
137 | + /* Means this RAMInfo is for QEMU's "system memory" */ | ||
138 | + MachineState *machine = MACHINE(mms); | ||
139 | + return machine->ram; | ||
140 | + } | 39 | + } |
141 | + | 40 | + |
142 | + assert(raminfo->mrindex < MPS2TZ_RAM_MAX); | 41 | + reg_num = FIELD_EX32(val, PHYMNTNC, REG_ADDR); |
143 | + ram = &mms->ram[raminfo->mrindex]; | ||
144 | + | 42 | + |
145 | + memory_region_init_ram(ram, NULL, raminfo->name, | 43 | + switch (FIELD_EX32(val, PHYMNTNC, OP)) { |
146 | + raminfo->size, &error_fatal); | 44 | + case MDIO_OP_READ: |
147 | + return ram; | 45 | + s->regs[R_PHYMNTNC] = FIELD_DP32(val, PHYMNTNC, DATA, |
148 | +} | 46 | + gem_phy_read(s, reg_num)); |
47 | + break; | ||
149 | + | 48 | + |
150 | /* Create an alias of an entire original MemoryRegion @orig | 49 | + case MDIO_OP_WRITE: |
151 | * located at @base in the memory map. | 50 | + gem_phy_write(s, reg_num, val); |
152 | */ | 51 | + break; |
153 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | ||
154 | const int *irqs) | ||
155 | { | ||
156 | TZMPC *mpc = opaque; | ||
157 | - int i = mpc - &mms->ssram_mpc[0]; | ||
158 | - MemoryRegion *ssram = &mms->ssram[i]; | ||
159 | + int i = mpc - &mms->mpc[0]; | ||
160 | MemoryRegion *upstream; | ||
161 | - char *mpcname = g_strdup_printf("%s-mpc", name); | ||
162 | - static uint32_t ramsize[] = { 0x00400000, 0x00200000, 0x00200000 }; | ||
163 | - static uint32_t rambase[] = { 0x00000000, 0x28000000, 0x28200000 }; | ||
164 | + const RAMInfo *raminfo = find_raminfo_for_mpc(mms, i); | ||
165 | + MemoryRegion *ram = mr_for_raminfo(mms, raminfo); | ||
166 | |||
167 | - memory_region_init_ram(ssram, NULL, name, ramsize[i], &error_fatal); | ||
168 | - | ||
169 | - object_initialize_child(OBJECT(mms), mpcname, mpc, TYPE_TZ_MPC); | ||
170 | - object_property_set_link(OBJECT(mpc), "downstream", OBJECT(ssram), | ||
171 | + object_initialize_child(OBJECT(mms), name, mpc, TYPE_TZ_MPC); | ||
172 | + object_property_set_link(OBJECT(mpc), "downstream", OBJECT(ram), | ||
173 | &error_fatal); | ||
174 | sysbus_realize(SYS_BUS_DEVICE(mpc), &error_fatal); | ||
175 | /* Map the upstream end of the MPC into system memory */ | ||
176 | upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 1); | ||
177 | - memory_region_add_subregion(get_system_memory(), rambase[i], upstream); | ||
178 | + memory_region_add_subregion(get_system_memory(), raminfo->base, upstream); | ||
179 | /* and connect its interrupt to the IoTKit */ | ||
180 | qdev_connect_gpio_out_named(DEVICE(mpc), "irq", 0, | ||
181 | qdev_get_gpio_in_named(DEVICE(&mms->iotkit), | ||
182 | "mpcexp_status", i)); | ||
183 | |||
184 | - /* The first SSRAM is a special case as it has an alias; accesses to | ||
185 | - * the alias region at 0x00400000 must also go to the MPC upstream. | ||
186 | - */ | ||
187 | - if (i == 0) { | ||
188 | - make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", upstream, 0x00400000); | ||
189 | - } | ||
190 | - | ||
191 | - g_free(mpcname); | ||
192 | /* Return the register interface MR for our caller to map behind the PPC */ | ||
193 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0); | ||
194 | } | ||
195 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_i2c(MPS2TZMachineState *mms, void *opaque, | ||
196 | return sysbus_mmio_get_region(s, 0); | ||
197 | } | ||
198 | |||
199 | +static void create_non_mpc_ram(MPS2TZMachineState *mms) | ||
200 | +{ | ||
201 | + /* | ||
202 | + * Handle the RAMs which are either not behind MPCs or which are | ||
203 | + * aliases to another MPC. | ||
204 | + */ | ||
205 | + const RAMInfo *p; | ||
206 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
207 | + | 52 | + |
208 | + for (p = mmc->raminfo; p->name; p++) { | 53 | + default: |
209 | + if (p->flags & IS_ALIAS) { | 54 | + break; /* only clause 22 operations are supported */ |
210 | + SysBusDevice *mpc_sbd = SYS_BUS_DEVICE(&mms->mpc[p->mpc]); | ||
211 | + MemoryRegion *upstream = sysbus_mmio_get_region(mpc_sbd, 1); | ||
212 | + make_ram_alias(&mms->ram[p->mrindex], p->name, upstream, p->base); | ||
213 | + } else if (p->mpc == -1) { | ||
214 | + /* RAM not behind an MPC */ | ||
215 | + MemoryRegion *mr = mr_for_raminfo(mms, p); | ||
216 | + memory_region_add_subregion(get_system_memory(), p->base, mr); | ||
217 | + } | ||
218 | + } | 55 | + } |
219 | +} | 56 | +} |
220 | + | 57 | + |
221 | static void mps2tz_common_init(MachineState *machine) | 58 | /* |
222 | { | 59 | * gem_read32: |
223 | MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine); | 60 | * Read a GEM register. |
224 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 61 | @@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) |
225 | qdev_connect_gpio_out_named(iotkitdev, "sec_resp_cfg", 0, | 62 | DB_PRINT("lowering irqs on ISR read\n"); |
226 | qdev_get_gpio_in(dev_splitter, 0)); | 63 | /* The interrupts get updated at the end of the function. */ |
227 | 64 | break; | |
228 | - /* The IoTKit sets up much of the memory layout, including | 65 | - case R_PHYMNTNC: |
229 | + /* | 66 | - if (FIELD_EX32(retval, PHYMNTNC, OP) == MDIO_OP_READ) { |
230 | + * The IoTKit sets up much of the memory layout, including | 67 | - uint32_t phy_addr, reg_num; |
231 | * the aliases between secure and non-secure regions in the | ||
232 | - * address space. The FPGA itself contains: | ||
233 | - * | ||
234 | - * 0x00000000..0x003fffff SSRAM1 | ||
235 | - * 0x00400000..0x007fffff alias of SSRAM1 | ||
236 | - * 0x28000000..0x283fffff 4MB SSRAM2 + SSRAM3 | ||
237 | - * 0x40100000..0x4fffffff AHB Master Expansion 1 interface devices | ||
238 | - * 0x80000000..0x80ffffff 16MB PSRAM | ||
239 | - */ | ||
240 | - | 68 | - |
241 | - /* The FPGA images have an odd combination of different RAMs, | 69 | - phy_addr = FIELD_EX32(retval, PHYMNTNC, PHY_ADDR); |
242 | + * address space, and also most of the devices in the system. | 70 | - if (phy_addr == s->phy_addr) { |
243 | + * The FPGA itself contains various RAMs and some additional devices. | 71 | - reg_num = FIELD_EX32(retval, PHYMNTNC, REG_ADDR); |
244 | + * The FPGA images have an odd combination of different RAMs, | 72 | - retval &= 0xFFFF0000; |
245 | * because in hardware they are different implementations and | 73 | - retval |= gem_phy_read(s, reg_num); |
246 | * connected to different buses, giving varying performance/size | 74 | - } else { |
247 | * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily | 75 | - retval |= 0xFFFF; /* No device at this address */ |
248 | - * call the 16MB our "system memory", as it's the largest lump. | 76 | - } |
249 | + * call the largest lump our "system memory". | 77 | - } |
250 | */ | 78 | - break; |
251 | - memory_region_add_subregion(system_memory, 0x80000000, machine->ram); | 79 | } |
252 | 80 | ||
253 | /* | 81 | /* Squash read to clear bits */ |
254 | * The overflow IRQs for all UARTs are ORed together. | 82 | @@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val, |
255 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 83 | s->sar_active[(offset - R_SPADDR1HI) / 2] = true; |
256 | const PPCInfo an505_ppcs[] = { { | 84 | break; |
257 | .name = "apb_ppcexp0", | 85 | case R_PHYMNTNC: |
258 | .ports = { | 86 | - if (FIELD_EX32(val, PHYMNTNC, OP) == MDIO_OP_WRITE) { |
259 | - { "ssram-0", make_mpc, &mms->ssram_mpc[0], 0x58007000, 0x1000 }, | 87 | - uint32_t phy_addr, reg_num; |
260 | - { "ssram-1", make_mpc, &mms->ssram_mpc[1], 0x58008000, 0x1000 }, | 88 | - |
261 | - { "ssram-2", make_mpc, &mms->ssram_mpc[2], 0x58009000, 0x1000 }, | 89 | - phy_addr = FIELD_EX32(val, PHYMNTNC, PHY_ADDR); |
262 | + { "ssram-0-mpc", make_mpc, &mms->mpc[0], 0x58007000, 0x1000 }, | 90 | - if (phy_addr == s->phy_addr) { |
263 | + { "ssram-1-mpc", make_mpc, &mms->mpc[1], 0x58008000, 0x1000 }, | 91 | - reg_num = FIELD_EX32(val, PHYMNTNC, REG_ADDR); |
264 | + { "ssram-2-mpc", make_mpc, &mms->mpc[2], 0x58009000, 0x1000 }, | 92 | - gem_phy_write(s, reg_num, val); |
265 | }, | 93 | - } |
266 | }, { | 94 | - } |
267 | .name = "apb_ppcexp1", | 95 | + gem_handle_phy_access(s); |
268 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 96 | break; |
269 | 97 | } | |
270 | create_unimplemented_device("FPGA NS PC", 0x48007000, 0x1000); | ||
271 | |||
272 | + create_non_mpc_ram(mms); | ||
273 | + | ||
274 | armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x400000); | ||
275 | } | ||
276 | |||
277 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | ||
278 | mmc->fpgaio_num_leds = 2; | ||
279 | mmc->fpgaio_has_switches = false; | ||
280 | mmc->numirq = 92; | ||
281 | + mmc->raminfo = an505_raminfo; | ||
282 | mmc->armsse_type = TYPE_IOTKIT; | ||
283 | } | ||
284 | |||
285 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_an521_class_init(ObjectClass *oc, void *data) | ||
286 | mmc->fpgaio_num_leds = 2; | ||
287 | mmc->fpgaio_has_switches = false; | ||
288 | mmc->numirq = 92; | ||
289 | + mmc->raminfo = an505_raminfo; /* AN521 is the same as AN505 here */ | ||
290 | mmc->armsse_type = TYPE_SSE200; | ||
291 | } | ||
292 | 98 | ||
293 | -- | 99 | -- |
294 | 2.20.1 | 100 | 2.34.1 |
295 | |||
296 | diff view generated by jsdifflib |
1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | 1 | From: Luc Michel <luc.michel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Cortex-A53 supports 40bits of address space. sbsa-ref's memory starts | 3 | The CRC was stored in an unsigned variable in gem_receive. Change it for |
4 | above this limit. | 4 | a uint32_t to ensure we have the correct variable size here. |
5 | 5 | ||
6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | 6 | Signed-off-by: Luc Michel <luc.michel@amd.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Acked-by: Leif Lindholm <leif@nuviainc.com> | 8 | Reviewed-by: sai.pavan.boddu@amd.com |
9 | Message-id: 20210216150122.3830863-2-marcin.juszkiewicz@linaro.org | 9 | Message-id: 20231017194422.4124691-12-luc.michel@amd.com |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | hw/arm/sbsa-ref.c | 1 - | 12 | hw/net/cadence_gem.c | 2 +- |
13 | 1 file changed, 1 deletion(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 14 | ||
15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 15 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/sbsa-ref.c | 17 | --- a/hw/net/cadence_gem.c |
18 | +++ b/hw/arm/sbsa-ref.c | 18 | +++ b/hw/net/cadence_gem.c |
19 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { | 19 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) |
20 | }; | 20 | if (FIELD_EX32(s->regs[R_NWCFG], NWCFG, FCS_REMOVE)) { |
21 | 21 | rxbuf_ptr = (void *)buf; | |
22 | static const char * const valid_cpus[] = { | 22 | } else { |
23 | - ARM_CPU_TYPE_NAME("cortex-a53"), | 23 | - unsigned crc_val; |
24 | ARM_CPU_TYPE_NAME("cortex-a57"), | 24 | + uint32_t crc_val; |
25 | ARM_CPU_TYPE_NAME("cortex-a72"), | 25 | |
26 | }; | 26 | if (size > MAX_FRAME_SIZE - sizeof(crc_val)) { |
27 | size = MAX_FRAME_SIZE - sizeof(crc_val); | ||
27 | -- | 28 | -- |
28 | 2.20.1 | 29 | 2.34.1 |
29 | 30 | ||
30 | 31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For a long time now the UI layer has guaranteed that the console | ||
2 | surface is always 32 bits per pixel RGB. Remove the legacy dead | ||
3 | code from the tc6393xb display device which was handling the | ||
4 | possibility that the console surface was some other format. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210215103215.4944-3-peter.maydell@linaro.org | ||
9 | --- | ||
10 | include/ui/console.h | 10 ---------- | ||
11 | hw/display/tc6393xb.c | 33 +-------------------------------- | ||
12 | 2 files changed, 1 insertion(+), 42 deletions(-) | ||
13 | |||
14 | diff --git a/include/ui/console.h b/include/ui/console.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/ui/console.h | ||
17 | +++ b/include/ui/console.h | ||
18 | @@ -XXX,XX +XXX,XX @@ PixelFormat qemu_default_pixelformat(int bpp); | ||
19 | DisplaySurface *qemu_create_displaysurface(int width, int height); | ||
20 | void qemu_free_displaysurface(DisplaySurface *surface); | ||
21 | |||
22 | -static inline int is_surface_bgr(DisplaySurface *surface) | ||
23 | -{ | ||
24 | - if (PIXMAN_FORMAT_BPP(surface->format) == 32 && | ||
25 | - PIXMAN_FORMAT_TYPE(surface->format) == PIXMAN_TYPE_ABGR) { | ||
26 | - return 1; | ||
27 | - } else { | ||
28 | - return 0; | ||
29 | - } | ||
30 | -} | ||
31 | - | ||
32 | static inline int is_buffer_shared(DisplaySurface *surface) | ||
33 | { | ||
34 | return !(surface->flags & QEMU_ALLOCATED_FLAG); | ||
35 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/display/tc6393xb.c | ||
38 | +++ b/hw/display/tc6393xb.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void tc6393xb_nand_writeb(TC6393xbState *s, hwaddr addr, uint32_t value) | ||
40 | (uint32_t) addr, value & 0xff); | ||
41 | } | ||
42 | |||
43 | -#define BITS 8 | ||
44 | -#include "tc6393xb_template.h" | ||
45 | -#define BITS 15 | ||
46 | -#include "tc6393xb_template.h" | ||
47 | -#define BITS 16 | ||
48 | -#include "tc6393xb_template.h" | ||
49 | -#define BITS 24 | ||
50 | -#include "tc6393xb_template.h" | ||
51 | #define BITS 32 | ||
52 | #include "tc6393xb_template.h" | ||
53 | |||
54 | static void tc6393xb_draw_graphic(TC6393xbState *s, int full_update) | ||
55 | { | ||
56 | - DisplaySurface *surface = qemu_console_surface(s->con); | ||
57 | - | ||
58 | - switch (surface_bits_per_pixel(surface)) { | ||
59 | - case 8: | ||
60 | - tc6393xb_draw_graphic8(s); | ||
61 | - break; | ||
62 | - case 15: | ||
63 | - tc6393xb_draw_graphic15(s); | ||
64 | - break; | ||
65 | - case 16: | ||
66 | - tc6393xb_draw_graphic16(s); | ||
67 | - break; | ||
68 | - case 24: | ||
69 | - tc6393xb_draw_graphic24(s); | ||
70 | - break; | ||
71 | - case 32: | ||
72 | - tc6393xb_draw_graphic32(s); | ||
73 | - break; | ||
74 | - default: | ||
75 | - printf("tc6393xb: unknown depth %d\n", | ||
76 | - surface_bits_per_pixel(surface)); | ||
77 | - return; | ||
78 | - } | ||
79 | - | ||
80 | + tc6393xb_draw_graphic32(s); | ||
81 | dpy_gfx_update_full(s->con); | ||
82 | } | ||
83 | |||
84 | -- | ||
85 | 2.20.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Now the template header is included only for BITS==32, expand | ||
2 | out all the macros that depended on the BITS setting. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210215103215.4944-4-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/display/tc6393xb_template.h | 35 ++++------------------------------ | ||
9 | 1 file changed, 4 insertions(+), 31 deletions(-) | ||
10 | |||
11 | diff --git a/hw/display/tc6393xb_template.h b/hw/display/tc6393xb_template.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/display/tc6393xb_template.h | ||
14 | +++ b/hw/display/tc6393xb_template.h | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | -#if BITS == 8 | ||
20 | -# define SET_PIXEL(addr, color) (*(uint8_t *)addr = color) | ||
21 | -#elif BITS == 15 || BITS == 16 | ||
22 | -# define SET_PIXEL(addr, color) (*(uint16_t *)addr = color) | ||
23 | -#elif BITS == 24 | ||
24 | -# define SET_PIXEL(addr, color) \ | ||
25 | - do { \ | ||
26 | - addr[0] = color; \ | ||
27 | - addr[1] = (color) >> 8; \ | ||
28 | - addr[2] = (color) >> 16; \ | ||
29 | - } while (0) | ||
30 | -#elif BITS == 32 | ||
31 | -# define SET_PIXEL(addr, color) (*(uint32_t *)addr = color) | ||
32 | -#else | ||
33 | -# error unknown bit depth | ||
34 | -#endif | ||
35 | - | ||
36 | - | ||
37 | -static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s) | ||
38 | +static void tc6393xb_draw_graphic32(TC6393xbState *s) | ||
39 | { | ||
40 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
41 | int i; | ||
42 | @@ -XXX,XX +XXX,XX @@ static void glue(tc6393xb_draw_graphic, BITS)(TC6393xbState *s) | ||
43 | data_buffer = s->vram_ptr; | ||
44 | data_display = surface_data(surface); | ||
45 | for(i = 0; i < s->scr_height; i++) { | ||
46 | -#if (BITS == 16) | ||
47 | - memcpy(data_display, data_buffer, s->scr_width * 2); | ||
48 | - data_buffer += s->scr_width; | ||
49 | - data_display += surface_stride(surface); | ||
50 | -#else | ||
51 | int j; | ||
52 | - for (j = 0; j < s->scr_width; j++, data_display += BITS / 8, data_buffer++) { | ||
53 | + for (j = 0; j < s->scr_width; j++, data_display += 4, data_buffer++) { | ||
54 | uint16_t color = *data_buffer; | ||
55 | - uint32_t dest_color = glue(rgb_to_pixel, BITS)( | ||
56 | + uint32_t dest_color = rgb_to_pixel32( | ||
57 | ((color & 0xf800) * 0x108) >> 11, | ||
58 | ((color & 0x7e0) * 0x41) >> 9, | ||
59 | ((color & 0x1f) * 0x21) >> 2 | ||
60 | ); | ||
61 | - SET_PIXEL(data_display, dest_color); | ||
62 | + *(uint32_t *)data_display = dest_color; | ||
63 | } | ||
64 | -#endif | ||
65 | } | ||
66 | } | ||
67 | - | ||
68 | -#undef BITS | ||
69 | -#undef SET_PIXEL | ||
70 | -- | ||
71 | 2.20.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The function tc6393xb_draw_graphic32() is called in exactly one place, | ||
2 | so just inline the function body at its callsite. This allows us to | ||
3 | drop the template header entirely. | ||
4 | 1 | ||
5 | The code move includes a single added space after 'for' to fix | ||
6 | the coding style. | ||
7 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20210215103215.4944-5-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/display/tc6393xb_template.h | 45 ---------------------------------- | ||
14 | hw/display/tc6393xb.c | 23 ++++++++++++++--- | ||
15 | 2 files changed, 19 insertions(+), 49 deletions(-) | ||
16 | delete mode 100644 hw/display/tc6393xb_template.h | ||
17 | |||
18 | diff --git a/hw/display/tc6393xb_template.h b/hw/display/tc6393xb_template.h | ||
19 | deleted file mode 100644 | ||
20 | index XXXXXXX..XXXXXXX | ||
21 | --- a/hw/display/tc6393xb_template.h | ||
22 | +++ /dev/null | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | -/* | ||
25 | - * Toshiba TC6393XB I/O Controller. | ||
26 | - * Found in Sharp Zaurus SL-6000 (tosa) or some | ||
27 | - * Toshiba e-Series PDAs. | ||
28 | - * | ||
29 | - * FB support code. Based on G364 fb emulator | ||
30 | - * | ||
31 | - * Copyright (c) 2007 Hervé Poussineau | ||
32 | - * | ||
33 | - * This program is free software; you can redistribute it and/or | ||
34 | - * modify it under the terms of the GNU General Public License as | ||
35 | - * published by the Free Software Foundation; either version 2 of | ||
36 | - * the License, or (at your option) any later version. | ||
37 | - * | ||
38 | - * This program is distributed in the hope that it will be useful, | ||
39 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
40 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
41 | - * GNU General Public License for more details. | ||
42 | - * | ||
43 | - * You should have received a copy of the GNU General Public License along | ||
44 | - * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
45 | - */ | ||
46 | - | ||
47 | -static void tc6393xb_draw_graphic32(TC6393xbState *s) | ||
48 | -{ | ||
49 | - DisplaySurface *surface = qemu_console_surface(s->con); | ||
50 | - int i; | ||
51 | - uint16_t *data_buffer; | ||
52 | - uint8_t *data_display; | ||
53 | - | ||
54 | - data_buffer = s->vram_ptr; | ||
55 | - data_display = surface_data(surface); | ||
56 | - for(i = 0; i < s->scr_height; i++) { | ||
57 | - int j; | ||
58 | - for (j = 0; j < s->scr_width; j++, data_display += 4, data_buffer++) { | ||
59 | - uint16_t color = *data_buffer; | ||
60 | - uint32_t dest_color = rgb_to_pixel32( | ||
61 | - ((color & 0xf800) * 0x108) >> 11, | ||
62 | - ((color & 0x7e0) * 0x41) >> 9, | ||
63 | - ((color & 0x1f) * 0x21) >> 2 | ||
64 | - ); | ||
65 | - *(uint32_t *)data_display = dest_color; | ||
66 | - } | ||
67 | - } | ||
68 | -} | ||
69 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/hw/display/tc6393xb.c | ||
72 | +++ b/hw/display/tc6393xb.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static void tc6393xb_nand_writeb(TC6393xbState *s, hwaddr addr, uint32_t value) | ||
74 | (uint32_t) addr, value & 0xff); | ||
75 | } | ||
76 | |||
77 | -#define BITS 32 | ||
78 | -#include "tc6393xb_template.h" | ||
79 | - | ||
80 | static void tc6393xb_draw_graphic(TC6393xbState *s, int full_update) | ||
81 | { | ||
82 | - tc6393xb_draw_graphic32(s); | ||
83 | + DisplaySurface *surface = qemu_console_surface(s->con); | ||
84 | + int i; | ||
85 | + uint16_t *data_buffer; | ||
86 | + uint8_t *data_display; | ||
87 | + | ||
88 | + data_buffer = s->vram_ptr; | ||
89 | + data_display = surface_data(surface); | ||
90 | + for (i = 0; i < s->scr_height; i++) { | ||
91 | + int j; | ||
92 | + for (j = 0; j < s->scr_width; j++, data_display += 4, data_buffer++) { | ||
93 | + uint16_t color = *data_buffer; | ||
94 | + uint32_t dest_color = rgb_to_pixel32( | ||
95 | + ((color & 0xf800) * 0x108) >> 11, | ||
96 | + ((color & 0x7e0) * 0x41) >> 9, | ||
97 | + ((color & 0x1f) * 0x21) >> 2 | ||
98 | + ); | ||
99 | + *(uint32_t *)data_display = dest_color; | ||
100 | + } | ||
101 | + } | ||
102 | dpy_gfx_update_full(s->con); | ||
103 | } | ||
104 | |||
105 | -- | ||
106 | 2.20.1 | ||
107 | |||
108 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The omap_lcdc template header is already only included once, for | ||
2 | DEPTH==32, but it still has all the macro-driven parameterization | ||
3 | for other depths. Expand out all the macros in the header. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210215103215.4944-6-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/display/omap_lcd_template.h | 67 ++++++++++++++-------------------- | ||
11 | 1 file changed, 28 insertions(+), 39 deletions(-) | ||
12 | |||
13 | diff --git a/hw/display/omap_lcd_template.h b/hw/display/omap_lcd_template.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/display/omap_lcd_template.h | ||
16 | +++ b/hw/display/omap_lcd_template.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
19 | */ | ||
20 | |||
21 | -#if DEPTH == 32 | ||
22 | -# define BPP 4 | ||
23 | -# define PIXEL_TYPE uint32_t | ||
24 | -#else | ||
25 | -# error unsupport depth | ||
26 | -#endif | ||
27 | - | ||
28 | /* | ||
29 | * 2-bit colour | ||
30 | */ | ||
31 | -static void glue(draw_line2_, DEPTH)(void *opaque, | ||
32 | - uint8_t *d, const uint8_t *s, int width, int deststep) | ||
33 | +static void draw_line2_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
34 | + int width, int deststep) | ||
35 | { | ||
36 | uint16_t *pal = opaque; | ||
37 | uint8_t v, r, g, b; | ||
38 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line2_, DEPTH)(void *opaque, | ||
39 | r = (pal[v & 3] >> 4) & 0xf0; | ||
40 | g = pal[v & 3] & 0xf0; | ||
41 | b = (pal[v & 3] << 4) & 0xf0; | ||
42 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
43 | - d += BPP; | ||
44 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
45 | + d += 4; | ||
46 | v >>= 2; | ||
47 | r = (pal[v & 3] >> 4) & 0xf0; | ||
48 | g = pal[v & 3] & 0xf0; | ||
49 | b = (pal[v & 3] << 4) & 0xf0; | ||
50 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
51 | - d += BPP; | ||
52 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
53 | + d += 4; | ||
54 | v >>= 2; | ||
55 | r = (pal[v & 3] >> 4) & 0xf0; | ||
56 | g = pal[v & 3] & 0xf0; | ||
57 | b = (pal[v & 3] << 4) & 0xf0; | ||
58 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
59 | - d += BPP; | ||
60 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
61 | + d += 4; | ||
62 | v >>= 2; | ||
63 | r = (pal[v & 3] >> 4) & 0xf0; | ||
64 | g = pal[v & 3] & 0xf0; | ||
65 | b = (pal[v & 3] << 4) & 0xf0; | ||
66 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
67 | - d += BPP; | ||
68 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
69 | + d += 4; | ||
70 | s ++; | ||
71 | width -= 4; | ||
72 | } while (width > 0); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line2_, DEPTH)(void *opaque, | ||
74 | /* | ||
75 | * 4-bit colour | ||
76 | */ | ||
77 | -static void glue(draw_line4_, DEPTH)(void *opaque, | ||
78 | - uint8_t *d, const uint8_t *s, int width, int deststep) | ||
79 | +static void draw_line4_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
80 | + int width, int deststep) | ||
81 | { | ||
82 | uint16_t *pal = opaque; | ||
83 | uint8_t v, r, g, b; | ||
84 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line4_, DEPTH)(void *opaque, | ||
85 | r = (pal[v & 0xf] >> 4) & 0xf0; | ||
86 | g = pal[v & 0xf] & 0xf0; | ||
87 | b = (pal[v & 0xf] << 4) & 0xf0; | ||
88 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
89 | - d += BPP; | ||
90 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
91 | + d += 4; | ||
92 | v >>= 4; | ||
93 | r = (pal[v & 0xf] >> 4) & 0xf0; | ||
94 | g = pal[v & 0xf] & 0xf0; | ||
95 | b = (pal[v & 0xf] << 4) & 0xf0; | ||
96 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
97 | - d += BPP; | ||
98 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
99 | + d += 4; | ||
100 | s ++; | ||
101 | width -= 2; | ||
102 | } while (width > 0); | ||
103 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line4_, DEPTH)(void *opaque, | ||
104 | /* | ||
105 | * 8-bit colour | ||
106 | */ | ||
107 | -static void glue(draw_line8_, DEPTH)(void *opaque, | ||
108 | - uint8_t *d, const uint8_t *s, int width, int deststep) | ||
109 | +static void draw_line8_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
110 | + int width, int deststep) | ||
111 | { | ||
112 | uint16_t *pal = opaque; | ||
113 | uint8_t v, r, g, b; | ||
114 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line8_, DEPTH)(void *opaque, | ||
115 | r = (pal[v] >> 4) & 0xf0; | ||
116 | g = pal[v] & 0xf0; | ||
117 | b = (pal[v] << 4) & 0xf0; | ||
118 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
119 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
120 | s ++; | ||
121 | - d += BPP; | ||
122 | + d += 4; | ||
123 | } while (-- width != 0); | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * 12-bit colour | ||
128 | */ | ||
129 | -static void glue(draw_line12_, DEPTH)(void *opaque, | ||
130 | - uint8_t *d, const uint8_t *s, int width, int deststep) | ||
131 | +static void draw_line12_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
132 | + int width, int deststep) | ||
133 | { | ||
134 | uint16_t v; | ||
135 | uint8_t r, g, b; | ||
136 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line12_, DEPTH)(void *opaque, | ||
137 | r = (v >> 4) & 0xf0; | ||
138 | g = v & 0xf0; | ||
139 | b = (v << 4) & 0xf0; | ||
140 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
141 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
142 | s += 2; | ||
143 | - d += BPP; | ||
144 | + d += 4; | ||
145 | } while (-- width != 0); | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * 16-bit colour | ||
150 | */ | ||
151 | -static void glue(draw_line16_, DEPTH)(void *opaque, | ||
152 | - uint8_t *d, const uint8_t *s, int width, int deststep) | ||
153 | +static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
154 | + int width, int deststep) | ||
155 | { | ||
156 | #if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) | ||
157 | memcpy(d, s, width * 2); | ||
158 | @@ -XXX,XX +XXX,XX @@ static void glue(draw_line16_, DEPTH)(void *opaque, | ||
159 | r = (v >> 8) & 0xf8; | ||
160 | g = (v >> 3) & 0xfc; | ||
161 | b = (v << 3) & 0xf8; | ||
162 | - ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); | ||
163 | + ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
164 | s += 2; | ||
165 | - d += BPP; | ||
166 | + d += 4; | ||
167 | } while (-- width != 0); | ||
168 | #endif | ||
169 | } | ||
170 | - | ||
171 | -#undef DEPTH | ||
172 | -#undef BPP | ||
173 | -#undef PIXEL_TYPE | ||
174 | -- | ||
175 | 2.20.1 | ||
176 | |||
177 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The draw_line16_32() function in the omap_lcdc template header | ||
2 | includes an ifdef for the case where HOST_WORDS_BIGENDIAN matches | ||
3 | TARGET_WORDS_BIGENDIAN. This is trying to optimise for "source | ||
4 | bitmap and destination bitmap format match", but it is broken, | ||
5 | because in this function the formats don't match: the source is | ||
6 | 16-bit colour and the destination is 32-bit colour, so a memcpy() | ||
7 | will produce corrupted graphics output. Drop the bogus ifdef. | ||
8 | 1 | ||
9 | This bug was introduced in commit ea644cf343129, when we dropped | ||
10 | support for DEPTH values other than 32 from the template header. | ||
11 | The old #if line was | ||
12 | #if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) | ||
13 | and this was mistakenly changed to | ||
14 | #if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) | ||
15 | rather than deleting the #if as now having an always-false condition. | ||
16 | |||
17 | Fixes: ea644cf343129 | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20210215103215.4944-7-peter.maydell@linaro.org | ||
22 | --- | ||
23 | hw/display/omap_lcd_template.h | 4 ---- | ||
24 | 1 file changed, 4 deletions(-) | ||
25 | |||
26 | diff --git a/hw/display/omap_lcd_template.h b/hw/display/omap_lcd_template.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/display/omap_lcd_template.h | ||
29 | +++ b/hw/display/omap_lcd_template.h | ||
30 | @@ -XXX,XX +XXX,XX @@ static void draw_line12_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
31 | static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
32 | int width, int deststep) | ||
33 | { | ||
34 | -#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) | ||
35 | - memcpy(d, s, width * 2); | ||
36 | -#else | ||
37 | uint16_t v; | ||
38 | uint8_t r, g, b; | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
41 | s += 2; | ||
42 | d += 4; | ||
43 | } while (-- width != 0); | ||
44 | -#endif | ||
45 | } | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Fix some minor coding style issues in the template header, | ||
2 | so checkpatch doesn't complain when we move the code. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20210215103215.4944-8-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/display/omap_lcd_template.h | 6 +++--- | ||
10 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/hw/display/omap_lcd_template.h b/hw/display/omap_lcd_template.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/display/omap_lcd_template.h | ||
15 | +++ b/hw/display/omap_lcd_template.h | ||
16 | @@ -XXX,XX +XXX,XX @@ static void draw_line2_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
17 | b = (pal[v & 3] << 4) & 0xf0; | ||
18 | ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
19 | d += 4; | ||
20 | - s ++; | ||
21 | + s++; | ||
22 | width -= 4; | ||
23 | } while (width > 0); | ||
24 | } | ||
25 | @@ -XXX,XX +XXX,XX @@ static void draw_line4_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
26 | b = (pal[v & 0xf] << 4) & 0xf0; | ||
27 | ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
28 | d += 4; | ||
29 | - s ++; | ||
30 | + s++; | ||
31 | width -= 2; | ||
32 | } while (width > 0); | ||
33 | } | ||
34 | @@ -XXX,XX +XXX,XX @@ static void draw_line8_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
35 | g = pal[v] & 0xf0; | ||
36 | b = (pal[v] << 4) & 0xf0; | ||
37 | ((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b); | ||
38 | - s ++; | ||
39 | + s++; | ||
40 | d += 4; | ||
41 | } while (-- width != 0); | ||
42 | } | ||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The macro draw_line_func is used only once; just expand it. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20210215103215.4944-10-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/display/omap_lcdc.c | 4 +--- | ||
9 | 1 file changed, 1 insertion(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/display/omap_lcdc.c | ||
14 | +++ b/hw/display/omap_lcdc.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) | ||
16 | qemu_irq_lower(s->irq); | ||
17 | } | ||
18 | |||
19 | -#define draw_line_func drawfn | ||
20 | - | ||
21 | /* | ||
22 | * 2-bit colour | ||
23 | */ | ||
24 | @@ -XXX,XX +XXX,XX @@ static void omap_update_display(void *opaque) | ||
25 | { | ||
26 | struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; | ||
27 | DisplaySurface *surface; | ||
28 | - draw_line_func draw_line; | ||
29 | + drawfn draw_line; | ||
30 | int size, height, first, last; | ||
31 | int width, linesize, step, bpp, frame_offset; | ||
32 | hwaddr frame_base; | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For a long time now the UI layer has guaranteed that the console | ||
2 | surface is always 32 bits per pixel, RGB. The TCX code already | ||
3 | assumes 32bpp, but it still has some checks of is_surface_bgr() | ||
4 | in an attempt to support 32bpp BGR. is_surface_bgr() will always | ||
5 | return false for the qemu_console_surface(), unless the display | ||
6 | device itself has deliberately created an alternate-format | ||
7 | surface via a function like qemu_create_displaysurface_from(). | ||
8 | 1 | ||
9 | Drop the never-used BGR-handling code, and assert that we have | ||
10 | a 32-bit surface rather than just doing nothing if it isn't. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20210215102149.20513-1-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/display/tcx.c | 31 ++++++++----------------------- | ||
18 | 1 file changed, 8 insertions(+), 23 deletions(-) | ||
19 | |||
20 | diff --git a/hw/display/tcx.c b/hw/display/tcx.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/display/tcx.c | ||
23 | +++ b/hw/display/tcx.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static int tcx_check_dirty(TCXState *s, DirtyBitmapSnapshot *snap, | ||
25 | |||
26 | static void update_palette_entries(TCXState *s, int start, int end) | ||
27 | { | ||
28 | - DisplaySurface *surface = qemu_console_surface(s->con); | ||
29 | int i; | ||
30 | |||
31 | for (i = start; i < end; i++) { | ||
32 | - if (is_surface_bgr(surface)) { | ||
33 | - s->palette[i] = rgb_to_pixel32bgr(s->r[i], s->g[i], s->b[i]); | ||
34 | - } else { | ||
35 | - s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]); | ||
36 | - } | ||
37 | + s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]); | ||
38 | } | ||
39 | tcx_set_dirty(s, 0, memory_region_size(&s->vram_mem)); | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static void tcx_draw_cursor32(TCXState *s1, uint8_t *d, | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | - XXX Could be much more optimal: | ||
46 | - * detect if line/page/whole screen is in 24 bit mode | ||
47 | - * if destination is also BGR, use memcpy | ||
48 | - */ | ||
49 | + * XXX Could be much more optimal: | ||
50 | + * detect if line/page/whole screen is in 24 bit mode | ||
51 | + */ | ||
52 | static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d, | ||
53 | const uint8_t *s, int width, | ||
54 | const uint32_t *cplane, | ||
55 | const uint32_t *s24) | ||
56 | { | ||
57 | - DisplaySurface *surface = qemu_console_surface(s1->con); | ||
58 | - int x, bgr, r, g, b; | ||
59 | + int x, r, g, b; | ||
60 | uint8_t val, *p8; | ||
61 | uint32_t *p = (uint32_t *)d; | ||
62 | uint32_t dval; | ||
63 | - bgr = is_surface_bgr(surface); | ||
64 | for(x = 0; x < width; x++, s++, s24++) { | ||
65 | if (be32_to_cpu(*cplane) & 0x03000000) { | ||
66 | /* 24-bit direct, BGR order */ | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d, | ||
68 | b = *p8++; | ||
69 | g = *p8++; | ||
70 | r = *p8; | ||
71 | - if (bgr) | ||
72 | - dval = rgb_to_pixel32bgr(r, g, b); | ||
73 | - else | ||
74 | - dval = rgb_to_pixel32(r, g, b); | ||
75 | + dval = rgb_to_pixel32(r, g, b); | ||
76 | } else { | ||
77 | /* 8-bit pseudocolor */ | ||
78 | val = *s; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void tcx_update_display(void *opaque) | ||
80 | int y, y_start, dd, ds; | ||
81 | uint8_t *d, *s; | ||
82 | |||
83 | - if (surface_bits_per_pixel(surface) != 32) { | ||
84 | - return; | ||
85 | - } | ||
86 | + assert(surface_bits_per_pixel(surface) == 32); | ||
87 | |||
88 | page = 0; | ||
89 | y_start = -1; | ||
90 | @@ -XXX,XX +XXX,XX @@ static void tcx24_update_display(void *opaque) | ||
91 | uint8_t *d, *s; | ||
92 | uint32_t *cptr, *s24; | ||
93 | |||
94 | - if (surface_bits_per_pixel(surface) != 32) { | ||
95 | - return; | ||
96 | - } | ||
97 | + assert(surface_bits_per_pixel(surface) == 32); | ||
98 | |||
99 | page = 0; | ||
100 | y_start = -1; | ||
101 | -- | ||
102 | 2.20.1 | ||
103 | |||
104 | diff view generated by jsdifflib |