1 | Last pullreq before 6.0 softfreeze: a few minor feature patches, | 1 | Some arm patches; my to-review queue is by no means empty, but |
---|---|---|---|
2 | some bugfixes, some cleanups. | 2 | this is a big enough set of patches to be getting on with... |
3 | 3 | ||
4 | -- PMM | 4 | -- PMM |
5 | 5 | ||
6 | The following changes since commit 6f34661b6c97a37a5efc27d31c037ddeda4547e2: | 6 | The following changes since commit cb9c6a8e5ad6a1f0ce164d352e3102df46986e22: |
7 | 7 | ||
8 | Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-6.0-pull-request' into staging (2021-03-11 18:55:27 +0000) | 8 | .gitlab-ci.d/windows: Work-around timeout and OpenGL problems of the MSYS2 jobs (2023-01-04 18:58:33 +0000) |
9 | 9 | ||
10 | are available in the Git repository at: | 10 | are available in the Git repository at: |
11 | 11 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210312-1 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230105 |
13 | 13 | ||
14 | for you to fetch changes up to 41f09f2e9f09e4dd386d84174a6dcb5136af17ca: | 14 | for you to fetch changes up to 93c9678de9dc7d2e68f9e8477da072bac30ef132: |
15 | 15 | ||
16 | hw/display/pxa2xx: Inline template header (2021-03-12 13:26:08 +0000) | 16 | hw/net: Fix read of uninitialized memory in imx_fec. (2023-01-05 15:33:00 +0000) |
17 | 17 | ||
18 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
19 | target-arm queue: | 19 | target-arm queue: |
20 | * versal: Support XRAMs and XRAM controller | 20 | * Implement AArch32 ARMv8-R support |
21 | * smmu: Various minor bug fixes | 21 | * Add Cortex-R52 CPU |
22 | * SVE emulation: fix bugs handling odd vector lengths | 22 | * fix handling of HLT semihosting in system mode |
23 | * allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value | 23 | * hw/timer/ixm_epit: cleanup and fix bug in compare handling |
24 | * tests/acceptance: fix orangepi-pc acceptance tests | 24 | * target/arm: Coding style fixes |
25 | * hw/timer/sse-timer: Propagate eventual error in sse_timer_realize() | 25 | * target/arm: Clean up includes |
26 | * hw/arm/virt: KVM: The IPA lower bound is 32 | 26 | * nseries: minor code cleanups |
27 | * npcm7xx: support MFT module | 27 | * target/arm: align exposed ID registers with Linux |
28 | * pl110, pxa2xx_lcd: tidy up template headers | 28 | * hw/arm/smmu-common: remove unnecessary inlines |
29 | * i.MX7D: Handle GPT timers | ||
30 | * i.MX7D: Connect IRQs to GPIO devices | ||
31 | * i.MX6UL: Add a specific GPT timer instance | ||
32 | * hw/net: Fix read of uninitialized memory in imx_fec | ||
29 | 33 | ||
30 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
31 | Andrew Jones (2): | 35 | Alex Bennée (1): |
32 | accel: kvm: Fix kvm_type invocation | 36 | target/arm: fix handling of HLT semihosting in system mode |
33 | hw/arm/virt: KVM: The IPA lower bound is 32 | ||
34 | 37 | ||
35 | Edgar E. Iglesias (2): | 38 | Axel Heider (8): |
36 | hw/misc: versal: Add a model of the XRAM controller | 39 | hw/timer/imx_epit: improve comments |
37 | hw/arm: versal: Add support for the XRAMs | 40 | hw/timer/imx_epit: cleanup CR defines |
41 | hw/timer/imx_epit: define SR_OCIF | ||
42 | hw/timer/imx_epit: update interrupt state on CR write access | ||
43 | hw/timer/imx_epit: hard reset initializes CR with 0 | ||
44 | hw/timer/imx_epit: factor out register write handlers | ||
45 | hw/timer/imx_epit: remove explicit fields cnt and freq | ||
46 | hw/timer/imx_epit: fix compare timer handling | ||
38 | 47 | ||
39 | Eric Auger (7): | 48 | Claudio Fontana (1): |
40 | intel_iommu: Fix mask may be uninitialized in vtd_context_device_invalidate | 49 | target/arm: cleanup cpu includes |
41 | dma: Introduce dma_aligned_pow2_mask() | ||
42 | virtio-iommu: Handle non power of 2 range invalidations | ||
43 | hw/arm/smmu-common: Fix smmu_iotlb_inv_iova when asid is not set | ||
44 | hw/arm/smmuv3: Enforce invalidation on a power of two range | ||
45 | hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling | ||
46 | hw/arm/smmuv3: Uniformize sid traces | ||
47 | 50 | ||
48 | Hao Wu (5): | 51 | Fabiano Rosas (5): |
49 | hw/misc: Add GPIOs for duty in NPCM7xx PWM | 52 | target/arm: Fix checkpatch comment style warnings in helper.c |
50 | hw/misc: Add NPCM7XX MFT Module | 53 | target/arm: Fix checkpatch space errors in helper.c |
51 | hw/arm: Add MFT device to NPCM7xx Soc | 54 | target/arm: Fix checkpatch brace errors in helper.c |
52 | hw/arm: Connect PWM fans in NPCM7XX boards | 55 | target/arm: Remove unused includes from m_helper.c |
53 | tests/qtest: Test PWM fan RPM using MFT in PWM test | 56 | target/arm: Remove unused includes from helper.c |
54 | 57 | ||
55 | Niek Linnenbank (5): | 58 | Jean-Christophe Dubois (4): |
56 | hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value | 59 | i.MX7D: Connect GPT timers to IRQ |
57 | tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic test for orangepi-pc machine | 60 | i.MX7D: Compute clock frequency for the fixed frequency clocks. |
58 | tests/acceptance/boot_linux_console: change URL for test_arm_orangepi_bionic_20_08 | 61 | i.MX6UL: Add a specific GPT timer instance for the i.MX6UL |
59 | tests/acceptance: update sunxi kernel from armbian to 5.10.16 | 62 | i.MX7D: Connect IRQs to GPIO devices. |
60 | tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for orangepi-pc, cubieboard tests | ||
61 | 63 | ||
62 | Peter Maydell (9): | 64 | Peter Maydell (1): |
63 | hw/display/pl110: Remove dead code for non-32-bpp surfaces | 65 | target/arm:Set lg_page_size to 0 if either S1 or S2 asks for it |
64 | hw/display/pl110: Pull included-once parts of template header into pl110.c | ||
65 | hw/display/pl110: Remove use of BITS from pl110_template.h | ||
66 | hw/display/pxa2xx_lcd: Remove dead code for non-32-bpp surfaces | ||
67 | hw/display/pxa2xx_lcd: Remove dest_width state field | ||
68 | hw/display/pxa2xx: Remove use of BITS in pxa2xx_template.h | ||
69 | hw/display/pxa2xx: Apply brace-related coding style fixes to template header | ||
70 | hw/display/pxa2xx: Apply whitespace-only coding style fixes to template header | ||
71 | hw/display/pxa2xx: Inline template header | ||
72 | 66 | ||
73 | Philippe Mathieu-Daudé (1): | 67 | Philippe Mathieu-Daudé (5): |
74 | hw/timer/sse-timer: Propagate eventual error in sse_timer_realize() | 68 | hw/input/tsc2xxx: Constify set_transform()'s MouseTransformInfo arg |
69 | hw/arm/nseries: Constify various read-only arrays | ||
70 | hw/arm/nseries: Silent -Wmissing-field-initializers warning | ||
71 | hw/arm/smmu-common: Reduce smmu_inv_notifiers_mr() scope | ||
72 | hw/arm/smmu-common: Avoid using inlined functions with external linkage | ||
75 | 73 | ||
76 | Richard Henderson (8): | 74 | Stephen Longfield (1): |
77 | target/arm: Fix sve_uzp_p vs odd vector lengths | 75 | hw/net: Fix read of uninitialized memory in imx_fec. |
78 | target/arm: Fix sve_zip_p vs odd vector lengths | ||
79 | target/arm: Fix sve_punpk_p vs odd vector lengths | ||
80 | target/arm: Update find_last_active for PREDDESC | ||
81 | target/arm: Update BRKA, BRKB, BRKN for PREDDESC | ||
82 | target/arm: Update CNTP for PREDDESC | ||
83 | target/arm: Update WHILE for PREDDESC | ||
84 | target/arm: Update sve reduction vs simd_desc | ||
85 | 76 | ||
86 | docs/system/arm/nuvoton.rst | 2 +- | 77 | Tobias Röhmel (7): |
87 | docs/system/arm/xlnx-versal-virt.rst | 1 + | 78 | target/arm: Don't add all MIDR aliases for cores that implement PMSA |
88 | hw/arm/smmu-internal.h | 5 + | 79 | target/arm: Make RVBAR available for all ARMv8 CPUs |
89 | hw/display/pl110_template.h | 120 +------- | 80 | target/arm: Make stage_2_format for cache attributes optional |
90 | hw/display/pxa2xx_template.h | 447 --------------------------- | 81 | target/arm: Enable TTBCR_EAE for ARMv8-R AArch32 |
91 | include/hw/arm/npcm7xx.h | 13 +- | 82 | target/arm: Add PMSAv8r registers |
92 | include/hw/arm/xlnx-versal.h | 13 + | 83 | target/arm: Add PMSAv8r functionality |
93 | include/hw/boards.h | 1 + | 84 | target/arm: Add ARM Cortex-R52 CPU |
94 | include/hw/misc/npcm7xx_mft.h | 70 +++++ | ||
95 | include/hw/misc/npcm7xx_pwm.h | 4 +- | ||
96 | include/hw/misc/xlnx-versal-xramc.h | 97 ++++++ | ||
97 | include/sysemu/dma.h | 12 + | ||
98 | target/arm/kvm_arm.h | 6 +- | ||
99 | accel/kvm/kvm-all.c | 2 + | ||
100 | hw/arm/npcm7xx.c | 45 ++- | ||
101 | hw/arm/npcm7xx_boards.c | 99 ++++++ | ||
102 | hw/arm/smmu-common.c | 32 +- | ||
103 | hw/arm/smmuv3.c | 58 ++-- | ||
104 | hw/arm/virt.c | 23 +- | ||
105 | hw/arm/xlnx-versal.c | 36 +++ | ||
106 | hw/display/pl110.c | 123 +++++--- | ||
107 | hw/display/pxa2xx_lcd.c | 520 ++++++++++++++++++++++++++----- | ||
108 | hw/i386/intel_iommu.c | 32 +- | ||
109 | hw/misc/npcm7xx_mft.c | 540 +++++++++++++++++++++++++++++++++ | ||
110 | hw/misc/npcm7xx_pwm.c | 4 + | ||
111 | hw/misc/xlnx-versal-xramc.c | 253 +++++++++++++++ | ||
112 | hw/net/allwinner-sun8i-emac.c | 62 ++-- | ||
113 | hw/timer/sse-timer.c | 1 + | ||
114 | hw/virtio/virtio-iommu.c | 19 +- | ||
115 | softmmu/dma-helpers.c | 26 ++ | ||
116 | target/arm/kvm.c | 4 +- | ||
117 | target/arm/sve_helper.c | 107 ++++--- | ||
118 | target/arm/translate-sve.c | 26 +- | ||
119 | tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++- | ||
120 | hw/arm/trace-events | 24 +- | ||
121 | hw/misc/meson.build | 2 + | ||
122 | hw/misc/trace-events | 8 + | ||
123 | tests/acceptance/boot_linux_console.py | 120 +++----- | ||
124 | tests/acceptance/replay_kernel.py | 10 +- | ||
125 | 39 files changed, 2235 insertions(+), 937 deletions(-) | ||
126 | delete mode 100644 hw/display/pxa2xx_template.h | ||
127 | create mode 100644 include/hw/misc/npcm7xx_mft.h | ||
128 | create mode 100644 include/hw/misc/xlnx-versal-xramc.h | ||
129 | create mode 100644 hw/misc/npcm7xx_mft.c | ||
130 | create mode 100644 hw/misc/xlnx-versal-xramc.c | ||
131 | 85 | ||
86 | Zhuojia Shen (1): | ||
87 | target/arm: align exposed ID registers with Linux | ||
88 | |||
89 | include/hw/arm/fsl-imx7.h | 20 + | ||
90 | include/hw/arm/smmu-common.h | 3 - | ||
91 | include/hw/input/tsc2xxx.h | 4 +- | ||
92 | include/hw/timer/imx_epit.h | 8 +- | ||
93 | include/hw/timer/imx_gpt.h | 1 + | ||
94 | target/arm/cpu.h | 6 + | ||
95 | target/arm/internals.h | 4 + | ||
96 | hw/arm/fsl-imx6ul.c | 2 +- | ||
97 | hw/arm/fsl-imx7.c | 41 +- | ||
98 | hw/arm/nseries.c | 28 +- | ||
99 | hw/arm/smmu-common.c | 15 +- | ||
100 | hw/input/tsc2005.c | 2 +- | ||
101 | hw/input/tsc210x.c | 3 +- | ||
102 | hw/misc/imx6ul_ccm.c | 6 - | ||
103 | hw/misc/imx7_ccm.c | 49 ++- | ||
104 | hw/net/imx_fec.c | 8 +- | ||
105 | hw/timer/imx_epit.c | 376 +++++++++------- | ||
106 | hw/timer/imx_gpt.c | 25 ++ | ||
107 | target/arm/cpu.c | 35 +- | ||
108 | target/arm/cpu64.c | 6 - | ||
109 | target/arm/cpu_tcg.c | 42 ++ | ||
110 | target/arm/debug_helper.c | 3 + | ||
111 | target/arm/helper.c | 871 +++++++++++++++++++++++++++++--------- | ||
112 | target/arm/m_helper.c | 16 - | ||
113 | target/arm/machine.c | 28 ++ | ||
114 | target/arm/ptw.c | 152 +++++-- | ||
115 | target/arm/tlb_helper.c | 4 + | ||
116 | target/arm/translate.c | 2 +- | ||
117 | tests/tcg/aarch64/sysregs.c | 24 +- | ||
118 | tests/tcg/aarch64/Makefile.target | 7 +- | ||
119 | 30 files changed, 1330 insertions(+), 461 deletions(-) | ||
120 | diff view generated by jsdifflib |
1 | Now that BITS is always 32, expand out all its uses in the template | 1 | In get_phys_addr_twostage() we set the lg_page_size of the result to |
---|---|---|---|
2 | header, including removing now-useless uses of the glue() macro. | 2 | the maximum of the stage 1 and stage 2 page sizes. This works for |
3 | the case where we do want to create a TLB entry, because we know the | ||
4 | common TLB code only creates entries of the TARGET_PAGE_SIZE and | ||
5 | asking for a size larger than that only means that invalidations | ||
6 | invalidate the whole larger area. However, if lg_page_size is | ||
7 | smaller than TARGET_PAGE_SIZE this effectively means "don't create a | ||
8 | TLB entry"; in this case if either S1 or S2 said "this covers less | ||
9 | than a page and can't go in a TLB" then the final result also should | ||
10 | be marked that way. Set the resulting page size to 0 if either | ||
11 | stage asked for a less-than-a-page entry, and expand the comment | ||
12 | to explain what's going on. | ||
13 | |||
14 | This has no effect for VMSA because currently the VMSA lookup always | ||
15 | returns results that cover at least TARGET_PAGE_SIZE; however when we | ||
16 | add v8R support it will reuse this code path, and for v8R the S1 and | ||
17 | S2 results can be smaller than TARGET_PAGE_SIZE. | ||
3 | 18 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20210211141515.8755-7-peter.maydell@linaro.org | 21 | Message-id: 20221212142708.610090-1-peter.maydell@linaro.org |
7 | --- | 22 | --- |
8 | hw/display/pxa2xx_template.h | 110 ++++++++++++++--------------------- | 23 | target/arm/ptw.c | 16 +++++++++++++--- |
9 | 1 file changed, 45 insertions(+), 65 deletions(-) | 24 | 1 file changed, 13 insertions(+), 3 deletions(-) |
10 | 25 | ||
11 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h | 26 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
12 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/display/pxa2xx_template.h | 28 | --- a/target/arm/ptw.c |
14 | +++ b/hw/display/pxa2xx_template.h | 29 | +++ b/target/arm/ptw.c |
15 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
16 | */ | ||
17 | |||
18 | # define SKIP_PIXEL(to) to += deststep | ||
19 | -#if BITS == 8 | ||
20 | -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) | ||
21 | -#elif BITS == 15 || BITS == 16 | ||
22 | -# define COPY_PIXEL(to, from) \ | ||
23 | - do { \ | ||
24 | - *(uint16_t *) to = from; \ | ||
25 | - SKIP_PIXEL(to); \ | ||
26 | - } while (0) | ||
27 | -#elif BITS == 24 | ||
28 | -# define COPY_PIXEL(to, from) \ | ||
29 | - do { \ | ||
30 | - *(uint16_t *) to = from; \ | ||
31 | - *(to + 2) = (from) >> 16; \ | ||
32 | - SKIP_PIXEL(to); \ | ||
33 | - } while (0) | ||
34 | -#elif BITS == 32 | ||
35 | # define COPY_PIXEL(to, from) \ | ||
36 | do { \ | ||
37 | *(uint32_t *) to = from; \ | ||
38 | SKIP_PIXEL(to); \ | ||
39 | } while (0) | ||
40 | -#else | ||
41 | -# error unknown bit depth | ||
42 | -#endif | ||
43 | |||
44 | #ifdef HOST_WORDS_BIGENDIAN | ||
45 | # define SWAP_WORDS 1 | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #define FN_2(x) FN(x + 1) FN(x) | ||
48 | #define FN_4(x) FN_2(x + 2) FN_2(x) | ||
49 | |||
50 | -static void glue(pxa2xx_draw_line2_, BITS)(void *opaque, | ||
51 | +static void pxa2xx_draw_line2(void *opaque, | ||
52 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
53 | { | ||
54 | uint32_t *palette = opaque; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line2_, BITS)(void *opaque, | ||
56 | } | 31 | } |
57 | } | 32 | |
58 | 33 | /* | |
59 | -static void glue(pxa2xx_draw_line4_, BITS)(void *opaque, | 34 | - * Use the maximum of the S1 & S2 page size, so that invalidation |
60 | +static void pxa2xx_draw_line4(void *opaque, | 35 | - * of pages > TARGET_PAGE_SIZE works correctly. |
61 | uint8_t *dest, const uint8_t *src, int width, int deststep) | 36 | + * If either S1 or S2 returned a result smaller than TARGET_PAGE_SIZE, |
62 | { | 37 | + * this means "don't put this in the TLB"; in this case, return a |
63 | uint32_t *palette = opaque; | 38 | + * result with lg_page_size == 0 to achieve that. Otherwise, |
64 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line4_, BITS)(void *opaque, | 39 | + * use the maximum of the S1 & S2 page size, so that invalidation |
40 | + * of pages > TARGET_PAGE_SIZE works correctly. (This works even though | ||
41 | + * we know the combined result permissions etc only cover the minimum | ||
42 | + * of the S1 and S2 page size, because we know that the common TLB code | ||
43 | + * never actually creates TLB entries bigger than TARGET_PAGE_SIZE, | ||
44 | + * and passing a larger page size value only affects invalidations.) | ||
45 | */ | ||
46 | - if (result->f.lg_page_size < s1_lgpgsz) { | ||
47 | + if (result->f.lg_page_size < TARGET_PAGE_BITS || | ||
48 | + s1_lgpgsz < TARGET_PAGE_BITS) { | ||
49 | + result->f.lg_page_size = 0; | ||
50 | + } else if (result->f.lg_page_size < s1_lgpgsz) { | ||
51 | result->f.lg_page_size = s1_lgpgsz; | ||
65 | } | 52 | } |
66 | } | ||
67 | |||
68 | -static void glue(pxa2xx_draw_line8_, BITS)(void *opaque, | ||
69 | +static void pxa2xx_draw_line8(void *opaque, | ||
70 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
71 | { | ||
72 | uint32_t *palette = opaque; | ||
73 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line8_, BITS)(void *opaque, | ||
74 | } | ||
75 | } | ||
76 | |||
77 | -static void glue(pxa2xx_draw_line16_, BITS)(void *opaque, | ||
78 | +static void pxa2xx_draw_line16(void *opaque, | ||
79 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
80 | { | ||
81 | uint32_t data; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16_, BITS)(void *opaque, | ||
83 | data >>= 6; | ||
84 | r = (data & 0x1f) << 3; | ||
85 | data >>= 5; | ||
86 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
87 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
88 | b = (data & 0x1f) << 3; | ||
89 | data >>= 5; | ||
90 | g = (data & 0x3f) << 2; | ||
91 | data >>= 6; | ||
92 | r = (data & 0x1f) << 3; | ||
93 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
94 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
95 | width -= 2; | ||
96 | src += 4; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | -static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque, | ||
101 | +static void pxa2xx_draw_line16t(void *opaque, | ||
102 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
103 | { | ||
104 | uint32_t data; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque, | ||
106 | if (data & 1) | ||
107 | SKIP_PIXEL(dest); | ||
108 | else | ||
109 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
110 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
111 | data >>= 1; | ||
112 | b = (data & 0x1f) << 3; | ||
113 | data >>= 5; | ||
114 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque, | ||
115 | if (data & 1) | ||
116 | SKIP_PIXEL(dest); | ||
117 | else | ||
118 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
119 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
120 | width -= 2; | ||
121 | src += 4; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | -static void glue(pxa2xx_draw_line18_, BITS)(void *opaque, | ||
126 | +static void pxa2xx_draw_line18(void *opaque, | ||
127 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
128 | { | ||
129 | uint32_t data; | ||
130 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line18_, BITS)(void *opaque, | ||
131 | g = (data & 0x3f) << 2; | ||
132 | data >>= 6; | ||
133 | r = (data & 0x3f) << 2; | ||
134 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
135 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
136 | width -= 1; | ||
137 | src += 4; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | /* The wicked packed format */ | ||
142 | -static void glue(pxa2xx_draw_line18p_, BITS)(void *opaque, | ||
143 | +static void pxa2xx_draw_line18p(void *opaque, | ||
144 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
145 | { | ||
146 | uint32_t data[3]; | ||
147 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line18p_, BITS)(void *opaque, | ||
148 | data[0] >>= 6; | ||
149 | r = (data[0] & 0x3f) << 2; | ||
150 | data[0] >>= 12; | ||
151 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
152 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
153 | b = (data[0] & 0x3f) << 2; | ||
154 | data[0] >>= 6; | ||
155 | g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
156 | data[1] >>= 4; | ||
157 | r = (data[1] & 0x3f) << 2; | ||
158 | data[1] >>= 12; | ||
159 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
160 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
161 | b = (data[1] & 0x3f) << 2; | ||
162 | data[1] >>= 6; | ||
163 | g = (data[1] & 0x3f) << 2; | ||
164 | data[1] >>= 6; | ||
165 | r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
166 | data[2] >>= 8; | ||
167 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
168 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
169 | b = (data[2] & 0x3f) << 2; | ||
170 | data[2] >>= 6; | ||
171 | g = (data[2] & 0x3f) << 2; | ||
172 | data[2] >>= 6; | ||
173 | r = data[2] << 2; | ||
174 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
175 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
176 | width -= 4; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | -static void glue(pxa2xx_draw_line19_, BITS)(void *opaque, | ||
181 | +static void pxa2xx_draw_line19(void *opaque, | ||
182 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
183 | { | ||
184 | uint32_t data; | ||
185 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19_, BITS)(void *opaque, | ||
186 | if (data & 1) | ||
187 | SKIP_PIXEL(dest); | ||
188 | else | ||
189 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
190 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
191 | width -= 1; | ||
192 | src += 4; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | /* The wicked packed format */ | ||
197 | -static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
198 | +static void pxa2xx_draw_line19p(void *opaque, | ||
199 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
200 | { | ||
201 | uint32_t data[3]; | ||
202 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
203 | if (data[0] & 1) | ||
204 | SKIP_PIXEL(dest); | ||
205 | else | ||
206 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
207 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
208 | data[0] >>= 6; | ||
209 | b = (data[0] & 0x3f) << 2; | ||
210 | data[0] >>= 6; | ||
211 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
212 | if (data[1] & 1) | ||
213 | SKIP_PIXEL(dest); | ||
214 | else | ||
215 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
216 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
217 | data[1] >>= 6; | ||
218 | b = (data[1] & 0x3f) << 2; | ||
219 | data[1] >>= 6; | ||
220 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
221 | if (data[2] & 1) | ||
222 | SKIP_PIXEL(dest); | ||
223 | else | ||
224 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
225 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
226 | data[2] >>= 6; | ||
227 | b = (data[2] & 0x3f) << 2; | ||
228 | data[2] >>= 6; | ||
229 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
230 | if (data[2] & 1) | ||
231 | SKIP_PIXEL(dest); | ||
232 | else | ||
233 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
234 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
235 | width -= 4; | ||
236 | } | ||
237 | } | ||
238 | |||
239 | -static void glue(pxa2xx_draw_line24_, BITS)(void *opaque, | ||
240 | +static void pxa2xx_draw_line24(void *opaque, | ||
241 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
242 | { | ||
243 | uint32_t data; | ||
244 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line24_, BITS)(void *opaque, | ||
245 | g = data & 0xff; | ||
246 | data >>= 8; | ||
247 | r = data & 0xff; | ||
248 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
249 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
250 | width -= 1; | ||
251 | src += 4; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | -static void glue(pxa2xx_draw_line24t_, BITS)(void *opaque, | ||
256 | +static void pxa2xx_draw_line24t(void *opaque, | ||
257 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
258 | { | ||
259 | uint32_t data; | ||
260 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line24t_, BITS)(void *opaque, | ||
261 | if (data & 1) | ||
262 | SKIP_PIXEL(dest); | ||
263 | else | ||
264 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
265 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
266 | width -= 1; | ||
267 | src += 4; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | -static void glue(pxa2xx_draw_line25_, BITS)(void *opaque, | ||
272 | +static void pxa2xx_draw_line25(void *opaque, | ||
273 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
274 | { | ||
275 | uint32_t data; | ||
276 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line25_, BITS)(void *opaque, | ||
277 | if (data & 1) | ||
278 | SKIP_PIXEL(dest); | ||
279 | else | ||
280 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
281 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
282 | width -= 1; | ||
283 | src += 4; | ||
284 | } | ||
285 | } | ||
286 | |||
287 | /* Overlay planes disabled, no transparency */ | ||
288 | -static drawfn glue(pxa2xx_draw_fn_, BITS)[16] = | ||
289 | +static drawfn pxa2xx_draw_fn_32[16] = | ||
290 | { | ||
291 | [0 ... 0xf] = NULL, | ||
292 | - [pxa_lcdc_2bpp] = glue(pxa2xx_draw_line2_, BITS), | ||
293 | - [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS), | ||
294 | - [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS), | ||
295 | - [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16_, BITS), | ||
296 | - [pxa_lcdc_18bpp] = glue(pxa2xx_draw_line18_, BITS), | ||
297 | - [pxa_lcdc_18pbpp] = glue(pxa2xx_draw_line18p_, BITS), | ||
298 | - [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24_, BITS), | ||
299 | + [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
300 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
301 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
302 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16, | ||
303 | + [pxa_lcdc_18bpp] = pxa2xx_draw_line18, | ||
304 | + [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p, | ||
305 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24, | ||
306 | }; | ||
307 | |||
308 | /* Overlay planes enabled, transparency used */ | ||
309 | -static drawfn glue(glue(pxa2xx_draw_fn_, BITS), t)[16] = | ||
310 | +static drawfn pxa2xx_draw_fn_32t[16] = | ||
311 | { | ||
312 | [0 ... 0xf] = NULL, | ||
313 | - [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS), | ||
314 | - [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS), | ||
315 | - [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16t_, BITS), | ||
316 | - [pxa_lcdc_19bpp] = glue(pxa2xx_draw_line19_, BITS), | ||
317 | - [pxa_lcdc_19pbpp] = glue(pxa2xx_draw_line19p_, BITS), | ||
318 | - [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24t_, BITS), | ||
319 | - [pxa_lcdc_25bpp] = glue(pxa2xx_draw_line25_, BITS), | ||
320 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
321 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
322 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16t, | ||
323 | + [pxa_lcdc_19bpp] = pxa2xx_draw_line19, | ||
324 | + [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p, | ||
325 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24t, | ||
326 | + [pxa_lcdc_25bpp] = pxa2xx_draw_line25, | ||
327 | }; | ||
328 | |||
329 | -#undef BITS | ||
330 | #undef COPY_PIXEL | ||
331 | #undef SKIP_PIXEL | ||
332 | 53 | ||
333 | -- | 54 | -- |
334 | 2.20.1 | 55 | 2.25.1 |
335 | |||
336 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Wrote too much with punpk1 with vl % 512 != 0. | 3 | Cores with PMSA have the MPUIR register which has the |
4 | same encoding as the MIDR alias with opc2=4. So we only | ||
5 | add that alias if we are not realizing a core that | ||
6 | implements PMSA. | ||
4 | 7 | ||
8 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Message-id: 20221206102504.165775-2-tobias.roehmel@rwth-aachen.de |
8 | Message-id: 20210309155305.11301-4-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | target/arm/sve_helper.c | 4 ++-- | 14 | target/arm/helper.c | 13 +++++++++---- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 15 | 1 file changed, 9 insertions(+), 4 deletions(-) |
13 | 16 | ||
14 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/sve_helper.c | 19 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/sve_helper.c | 20 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_punpk_p)(void *vd, void *vn, uint32_t pred_desc) | 21 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
19 | high = oprsz >> 1; | 22 | .access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr, |
23 | .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), | ||
24 | .readfn = midr_read }, | ||
25 | - /* crn = 0 op1 = 0 crm = 0 op2 = 4,7 : AArch32 aliases of MIDR */ | ||
26 | - { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, | ||
27 | - .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, | ||
28 | - .access = PL1_R, .resetvalue = cpu->midr }, | ||
29 | + /* crn = 0 op1 = 0 crm = 0 op2 = 7 : AArch32 aliases of MIDR */ | ||
30 | { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, | ||
31 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 7, | ||
32 | .access = PL1_R, .resetvalue = cpu->midr }, | ||
33 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
34 | .accessfn = access_aa64_tid1, | ||
35 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
36 | }; | ||
37 | + ARMCPRegInfo id_v8_midr_alias_cp_reginfo = { | ||
38 | + .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, | ||
39 | + .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, | ||
40 | + .access = PL1_R, .resetvalue = cpu->midr | ||
41 | + }; | ||
42 | ARMCPRegInfo id_cp_reginfo[] = { | ||
43 | /* These are common to v8 and pre-v8 */ | ||
44 | { .name = "CTR", | ||
45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
20 | } | 46 | } |
21 | 47 | if (arm_feature(env, ARM_FEATURE_V8)) { | |
22 | - if ((high & 3) == 0) { | 48 | define_arm_cp_regs(cpu, id_v8_midr_cp_reginfo); |
23 | + if ((oprsz & 7) == 0) { | 49 | + if (!arm_feature(env, ARM_FEATURE_PMSA)) { |
24 | uint32_t *n = vn; | 50 | + define_one_arm_cp_reg(cpu, &id_v8_midr_alias_cp_reginfo); |
25 | high >>= 2; | 51 | + } |
26 | 52 | } else { | |
27 | - for (i = 0; i < DIV_ROUND_UP(oprsz, 8); i++) { | 53 | define_arm_cp_regs(cpu, id_pre_v8_midr_cp_reginfo); |
28 | + for (i = 0; i < oprsz / 8; i++) { | 54 | } |
29 | uint64_t nn = n[H4(high + i)]; | ||
30 | d[i] = expand_bits(nn, 0); | ||
31 | } | ||
32 | -- | 55 | -- |
33 | 2.20.1 | 56 | 2.25.1 |
34 | 57 | ||
35 | 58 | diff view generated by jsdifflib |
1 | For a long time now the UI layer has guaranteed that the console | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | surface is always 32 bits per pixel. Remove the legacy dead | ||
3 | code from the pl110 display device which was handling the | ||
4 | possibility that the console surface was some other format. | ||
5 | 2 | ||
3 | RVBAR shadows RVBAR_ELx where x is the highest exception | ||
4 | level if the highest EL is not EL3. This patch also allows | ||
5 | ARMv8 CPUs to change the reset address with | ||
6 | the rvbar property. | ||
7 | |||
8 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20221206102504.165775-3-tobias.roehmel@rwth-aachen.de | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
8 | Message-id: 20210211141515.8755-2-peter.maydell@linaro.org | ||
9 | --- | 12 | --- |
10 | hw/display/pl110.c | 53 +++++++--------------------------------------- | 13 | target/arm/cpu.c | 6 +++++- |
11 | 1 file changed, 8 insertions(+), 45 deletions(-) | 14 | target/arm/helper.c | 21 ++++++++++++++------- |
15 | 2 files changed, 19 insertions(+), 8 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/hw/display/pl110.c b/hw/display/pl110.c | 17 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/display/pl110.c | 19 | --- a/target/arm/cpu.c |
16 | +++ b/hw/display/pl110.c | 20 | +++ b/target/arm/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | 21 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) |
18 | pl111_id | 22 | env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
19 | }; | 23 | CPACR, CP11, 3); |
20 | 24 | #endif | |
21 | -#define BITS 8 | 25 | + if (arm_feature(env, ARM_FEATURE_V8)) { |
22 | -#include "pl110_template.h" | 26 | + env->cp15.rvbar = cpu->rvbar_prop; |
23 | -#define BITS 15 | 27 | + env->regs[15] = cpu->rvbar_prop; |
24 | -#include "pl110_template.h" | 28 | + } |
25 | -#define BITS 16 | 29 | } |
26 | -#include "pl110_template.h" | 30 | |
27 | -#define BITS 24 | 31 | #if defined(CONFIG_USER_ONLY) |
28 | -#include "pl110_template.h" | 32 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) |
29 | #define BITS 32 | 33 | qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_hivecs_property); |
30 | #include "pl110_template.h" | 34 | } |
31 | 35 | ||
32 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | 36 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
33 | PL110State *s = (PL110State *)opaque; | 37 | + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { |
34 | SysBusDevice *sbd; | 38 | object_property_add_uint64_ptr(obj, "rvbar", |
35 | DisplaySurface *surface = qemu_console_surface(s->con); | 39 | &cpu->rvbar_prop, |
36 | - drawfn* fntable; | 40 | OBJ_PROP_FLAG_READWRITE); |
37 | drawfn fn; | 41 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
38 | - int dest_width; | 42 | index XXXXXXX..XXXXXXX 100644 |
39 | int src_width; | 43 | --- a/target/arm/helper.c |
40 | int bpp_offset; | 44 | +++ b/target/arm/helper.c |
41 | int first; | 45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
42 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | 46 | if (!arm_feature(env, ARM_FEATURE_EL3) && |
43 | 47 | !arm_feature(env, ARM_FEATURE_EL2)) { | |
44 | sbd = SYS_BUS_DEVICE(s); | 48 | ARMCPRegInfo rvbar = { |
45 | 49 | - .name = "RVBAR_EL1", .state = ARM_CP_STATE_AA64, | |
46 | - switch (surface_bits_per_pixel(surface)) { | 50 | + .name = "RVBAR_EL1", .state = ARM_CP_STATE_BOTH, |
47 | - case 0: | 51 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1, |
48 | - return; | 52 | .access = PL1_R, |
49 | - case 8: | 53 | .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
50 | - fntable = pl110_draw_fn_8; | 54 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
51 | - dest_width = 1; | 55 | } |
52 | - break; | 56 | /* RVBAR_EL2 is only implemented if EL2 is the highest EL */ |
53 | - case 15: | 57 | if (!arm_feature(env, ARM_FEATURE_EL3)) { |
54 | - fntable = pl110_draw_fn_15; | 58 | - ARMCPRegInfo rvbar = { |
55 | - dest_width = 2; | 59 | - .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64, |
56 | - break; | 60 | - .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1, |
57 | - case 16: | 61 | - .access = PL2_R, |
58 | - fntable = pl110_draw_fn_16; | 62 | - .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
59 | - dest_width = 2; | 63 | + ARMCPRegInfo rvbar[] = { |
60 | - break; | 64 | + { |
61 | - case 24: | 65 | + .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64, |
62 | - fntable = pl110_draw_fn_24; | 66 | + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1, |
63 | - dest_width = 3; | 67 | + .access = PL2_R, |
64 | - break; | 68 | + .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
65 | - case 32: | 69 | + }, |
66 | - fntable = pl110_draw_fn_32; | 70 | + { .name = "RVBAR", .type = ARM_CP_ALIAS, |
67 | - dest_width = 4; | 71 | + .cp = 15, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1, |
68 | - break; | 72 | + .access = PL2_R, |
69 | - default: | 73 | + .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
70 | - fprintf(stderr, "pl110: Bad color depth\n"); | 74 | + }, |
71 | - exit(1); | 75 | }; |
72 | - } | 76 | - define_one_arm_cp_reg(cpu, &rvbar); |
73 | if (s->cr & PL110_CR_BGR) | 77 | + define_arm_cp_regs(cpu, rvbar); |
74 | bpp_offset = 0; | ||
75 | else | ||
76 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | ||
77 | } | 78 | } |
78 | } | 79 | } |
79 | 80 | ||
80 | - if (s->cr & PL110_CR_BEBO) | ||
81 | - fn = fntable[s->bpp + 8 + bpp_offset]; | ||
82 | - else if (s->cr & PL110_CR_BEPO) | ||
83 | - fn = fntable[s->bpp + 16 + bpp_offset]; | ||
84 | - else | ||
85 | - fn = fntable[s->bpp + bpp_offset]; | ||
86 | + if (s->cr & PL110_CR_BEBO) { | ||
87 | + fn = pl110_draw_fn_32[s->bpp + 8 + bpp_offset]; | ||
88 | + } else if (s->cr & PL110_CR_BEPO) { | ||
89 | + fn = pl110_draw_fn_32[s->bpp + 16 + bpp_offset]; | ||
90 | + } else { | ||
91 | + fn = pl110_draw_fn_32[s->bpp + bpp_offset]; | ||
92 | + } | ||
93 | |||
94 | src_width = s->cols; | ||
95 | switch (s->bpp) { | ||
96 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | ||
97 | src_width <<= 2; | ||
98 | break; | ||
99 | } | ||
100 | - dest_width *= s->cols; | ||
101 | first = 0; | ||
102 | if (s->invalidate) { | ||
103 | framebuffer_update_memory_section(&s->fbsection, | ||
104 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | ||
105 | |||
106 | framebuffer_update_display(surface, &s->fbsection, | ||
107 | s->cols, s->rows, | ||
108 | - src_width, dest_width, 0, | ||
109 | + src_width, s->cols * 4, 0, | ||
110 | s->invalidate, | ||
111 | fn, s->palette, | ||
112 | &first, &last); | ||
113 | -- | 81 | -- |
114 | 2.20.1 | 82 | 2.25.1 |
115 | 83 | ||
116 | 84 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Prior to commit f2ce39b4f067 a MachineClass kvm_type method | 3 | The v8R PMSAv8 has a two-stage MPU translation process, but, unlike |
4 | only needed to be registered to ensure it would be executed. | 4 | VMSAv8, the stage 2 attributes are in the same format as the stage 1 |
5 | With commit f2ce39b4f067 a kvm-type machine property must also | 5 | attributes (8-bit MAIR format). Rather than converting the MAIR |
6 | be specified. hw/arm/virt relies on the kvm_type method to pass | 6 | format to the format used for VMSA stage 2 (bits [5:2] of a VMSA |
7 | its selected IPA limit to KVM, but this is not exposed as a | 7 | stage 2 descriptor) and then converting back to do the attribute |
8 | machine property. Restore the previous functionality of invoking | 8 | combination, allow combined_attrs_nofwb() to accept s2 attributes |
9 | kvm_type when it's present. | 9 | that are already in the MAIR format. |
10 | 10 | ||
11 | Fixes: f2ce39b4f067 ("vl: make qemu_get_machine_opts static") | 11 | We move the assert() to combined_attrs_fwb(), because that function |
12 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 12 | really does require a VMSA stage 2 attribute format. (We will never |
13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 13 | get there for v8R, because PMSAv8 does not implement FEAT_S2FWB.) |
14 | Message-id: 20210310135218.255205-2-drjones@redhat.com | 14 | |
15 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Message-id: 20221206102504.165775-4-tobias.roehmel@rwth-aachen.de | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 19 | --- |
17 | include/hw/boards.h | 1 + | 20 | target/arm/ptw.c | 10 ++++++++-- |
18 | accel/kvm/kvm-all.c | 2 ++ | 21 | 1 file changed, 8 insertions(+), 2 deletions(-) |
19 | 2 files changed, 3 insertions(+) | ||
20 | 22 | ||
21 | diff --git a/include/hw/boards.h b/include/hw/boards.h | 23 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
22 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/boards.h | 25 | --- a/target/arm/ptw.c |
24 | +++ b/include/hw/boards.h | 26 | +++ b/target/arm/ptw.c |
25 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 27 | @@ -XXX,XX +XXX,XX @@ static uint8_t combined_attrs_nofwb(uint64_t hcr, |
26 | * @kvm_type: | 28 | { |
27 | * Return the type of KVM corresponding to the kvm-type string option or | 29 | uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; |
28 | * computed based on other criteria such as the host kernel capabilities. | 30 | |
29 | + * kvm-type may be NULL if it is not needed. | 31 | - s2_mair_attrs = convert_stage2_attrs(hcr, s2.attrs); |
30 | * @numa_mem_supported: | 32 | + if (s2.is_s2_format) { |
31 | * true if '--numa node.mem' option is supported and false otherwise | 33 | + s2_mair_attrs = convert_stage2_attrs(hcr, s2.attrs); |
32 | * @smp_parse: | 34 | + } else { |
33 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c | 35 | + s2_mair_attrs = s2.attrs; |
34 | index XXXXXXX..XXXXXXX 100644 | 36 | + } |
35 | --- a/accel/kvm/kvm-all.c | 37 | |
36 | +++ b/accel/kvm/kvm-all.c | 38 | s1lo = extract32(s1.attrs, 0, 4); |
37 | @@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms) | 39 | s2lo = extract32(s2_mair_attrs, 0, 4); |
38 | "kvm-type", | 40 | @@ -XXX,XX +XXX,XX @@ static uint8_t force_cacheattr_nibble_wb(uint8_t attr) |
39 | &error_abort); | 41 | */ |
40 | type = mc->kvm_type(ms, kvm_type); | 42 | static uint8_t combined_attrs_fwb(ARMCacheAttrs s1, ARMCacheAttrs s2) |
41 | + } else if (mc->kvm_type) { | 43 | { |
42 | + type = mc->kvm_type(ms, NULL); | 44 | + assert(s2.is_s2_format && !s1.is_s2_format); |
43 | } | 45 | + |
44 | 46 | switch (s2.attrs) { | |
45 | do { | 47 | case 7: |
48 | /* Use stage 1 attributes */ | ||
49 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr, | ||
50 | ARMCacheAttrs ret; | ||
51 | bool tagged = false; | ||
52 | |||
53 | - assert(s2.is_s2_format && !s1.is_s2_format); | ||
54 | + assert(!s1.is_s2_format); | ||
55 | ret.is_s2_format = false; | ||
56 | |||
57 | if (s1.attrs == 0xf0) { | ||
46 | -- | 58 | -- |
47 | 2.20.1 | 59 | 2.25.1 |
48 | 60 | ||
49 | 61 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Previously the ARMBIAN_ARTIFACTS_CACHED pre-condition was added to allow running | 3 | ARMv8-R AArch32 CPUs behave as if TTBCR.EAE is always 1 even |
4 | tests that have already existing armbian.com artifacts stored in the local avocado cache, | 4 | tough they don't have the TTBCR register. |
5 | but do not have working URLs to download a fresh copy. | 5 | See ARM Architecture Reference Manual Supplement - ARMv8, for the ARMv8-R |
6 | AArch32 architecture profile Version:A.c section C1.2. | ||
6 | 7 | ||
7 | At this time of writing the URLs for artifacts on the armbian.com server are updated and working. | 8 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
8 | Any future broken URLs will result in a skipped acceptance test, for example: | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | 10 | Message-id: 20221206102504.165775-5-tobias.roehmel@rwth-aachen.de | |
10 | (1/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi: | ||
11 | CANCEL: Missing asset https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb (0.53 s) | ||
12 | |||
13 | This commits removes the ARMBIAN_ARTIFACTS_CACHED pre-condition such that | ||
14 | the acceptance tests for the orangepi-pc and cubieboard machines can run. | ||
15 | |||
16 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
17 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
18 | Message-id: 20210310195820.21950-6-nieklinnenbank@gmail.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 12 | --- |
21 | tests/acceptance/boot_linux_console.py | 12 ------------ | 13 | target/arm/internals.h | 4 ++++ |
22 | tests/acceptance/replay_kernel.py | 2 -- | 14 | target/arm/debug_helper.c | 3 +++ |
23 | 2 files changed, 14 deletions(-) | 15 | target/arm/tlb_helper.c | 4 ++++ |
16 | 3 files changed, 11 insertions(+) | ||
24 | 17 | ||
25 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 18 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
26 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/tests/acceptance/boot_linux_console.py | 20 | --- a/target/arm/internals.h |
28 | +++ b/tests/acceptance/boot_linux_console.py | 21 | +++ b/target/arm/internals.h |
29 | @@ -XXX,XX +XXX,XX @@ def test_arm_exynos4210_initrd(self): | 22 | @@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu); |
30 | self.wait_for_console_pattern('Boot successful.') | 23 | static inline bool extended_addresses_enabled(CPUARMState *env) |
31 | # TODO user command, for now the uart is stuck | 24 | { |
32 | 25 | uint64_t tcr = env->cp15.tcr_el[arm_is_secure(env) ? 3 : 1]; | |
33 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | 26 | + if (arm_feature(env, ARM_FEATURE_PMSA) && |
34 | - 'Test artifacts fetched from unreliable apt.armbian.com') | 27 | + arm_feature(env, ARM_FEATURE_V8)) { |
35 | def test_arm_cubieboard_initrd(self): | 28 | + return true; |
36 | """ | 29 | + } |
37 | :avocado: tags=arch:arm | 30 | return arm_el_is_aa64(env, 1) || |
38 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): | 31 | (arm_feature(env, ARM_FEATURE_LPAE) && (tcr & TTBCR_EAE)); |
39 | 'system-control@1c00000') | 32 | } |
40 | # cubieboard's reboot is not functioning; omit reboot test. | 33 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
41 | |||
42 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
43 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
44 | def test_arm_cubieboard_sata(self): | ||
45 | """ | ||
46 | :avocado: tags=arch:arm | ||
47 | @@ -XXX,XX +XXX,XX @@ def test_arm_quanta_gsj_initrd(self): | ||
48 | self.wait_for_console_pattern( | ||
49 | 'Give root password for system maintenance') | ||
50 | |||
51 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
52 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
53 | def test_arm_orangepi(self): | ||
54 | """ | ||
55 | :avocado: tags=arch:arm | ||
56 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self): | ||
57 | console_pattern = 'Kernel command line: %s' % kernel_command_line | ||
58 | self.wait_for_console_pattern(console_pattern) | ||
59 | |||
60 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
61 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
62 | def test_arm_orangepi_initrd(self): | ||
63 | """ | ||
64 | :avocado: tags=arch:arm | ||
65 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self): | ||
66 | # Wait for VM to shut down gracefully | ||
67 | self.vm.wait() | ||
68 | |||
69 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
70 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
71 | def test_arm_orangepi_sd(self): | ||
72 | """ | ||
73 | :avocado: tags=arch:arm | ||
74 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): | ||
75 | # Wait for VM to shut down gracefully | ||
76 | self.vm.wait() | ||
77 | |||
78 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
79 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
80 | @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
81 | def test_arm_orangepi_bionic_20_08(self): | ||
82 | """ | ||
83 | diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py | ||
84 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
85 | --- a/tests/acceptance/replay_kernel.py | 35 | --- a/target/arm/debug_helper.c |
86 | +++ b/tests/acceptance/replay_kernel.py | 36 | +++ b/target/arm/debug_helper.c |
87 | @@ -XXX,XX +XXX,XX @@ def test_arm_virt(self): | 37 | @@ -XXX,XX +XXX,XX @@ static uint32_t arm_debug_exception_fsr(CPUARMState *env) |
88 | self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1) | 38 | |
89 | 39 | if (target_el == 2 || arm_el_is_aa64(env, target_el)) { | |
90 | @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | 40 | using_lpae = true; |
91 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | 41 | + } else if (arm_feature(env, ARM_FEATURE_PMSA) && |
92 | - 'Test artifacts fetched from unreliable apt.armbian.com') | 42 | + arm_feature(env, ARM_FEATURE_V8)) { |
93 | def test_arm_cubieboard_initrd(self): | 43 | + using_lpae = true; |
94 | """ | 44 | } else { |
95 | :avocado: tags=arch:arm | 45 | if (arm_feature(env, ARM_FEATURE_LPAE) && |
46 | (env->cp15.tcr_el[target_el] & TTBCR_EAE)) { | ||
47 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/tlb_helper.c | ||
50 | +++ b/target/arm/tlb_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) | ||
52 | if (el == 2 || arm_el_is_aa64(env, el)) { | ||
53 | return true; | ||
54 | } | ||
55 | + if (arm_feature(env, ARM_FEATURE_PMSA) && | ||
56 | + arm_feature(env, ARM_FEATURE_V8)) { | ||
57 | + return true; | ||
58 | + } | ||
59 | if (arm_feature(env, ARM_FEATURE_LPAE) | ||
60 | && (regime_tcr(env, mmu_idx) & TTBCR_EAE)) { | ||
61 | return true; | ||
96 | -- | 62 | -- |
97 | 2.20.1 | 63 | 2.25.1 |
98 | 64 | ||
99 | 65 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Add a model of the Xilinx Versal Accelerator RAM (XRAM). | 3 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
4 | This is mainly a stub to make firmware happy. The size of | 4 | Message-id: 20221206102504.165775-6-tobias.roehmel@rwth-aachen.de |
5 | the RAMs can be probed. The interrupt mask logic is | ||
6 | modelled but none of the interrups will ever be raised | ||
7 | unless injected. | ||
8 | |||
9 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
10 | Message-id: 20210308224637.2949533-2-edgar.iglesias@gmail.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 6 | --- |
14 | include/hw/misc/xlnx-versal-xramc.h | 97 +++++++++++ | 7 | target/arm/cpu.h | 6 + |
15 | hw/misc/xlnx-versal-xramc.c | 253 ++++++++++++++++++++++++++++ | 8 | target/arm/cpu.c | 28 +++- |
16 | hw/misc/meson.build | 1 + | 9 | target/arm/helper.c | 302 +++++++++++++++++++++++++++++++++++++++++++ |
17 | 3 files changed, 351 insertions(+) | 10 | target/arm/machine.c | 28 ++++ |
18 | create mode 100644 include/hw/misc/xlnx-versal-xramc.h | 11 | 4 files changed, 360 insertions(+), 4 deletions(-) |
19 | create mode 100644 hw/misc/xlnx-versal-xramc.c | ||
20 | 12 | ||
21 | diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h | 13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
22 | new file mode 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
23 | index XXXXXXX..XXXXXXX | 15 | --- a/target/arm/cpu.h |
24 | --- /dev/null | 16 | +++ b/target/arm/cpu.h |
25 | +++ b/include/hw/misc/xlnx-versal-xramc.h | 17 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
26 | @@ -XXX,XX +XXX,XX @@ | 18 | }; |
27 | +/* | 19 | uint64_t sctlr_el[4]; |
28 | + * QEMU model of the Xilinx XRAM Controller. | 20 | }; |
29 | + * | 21 | + uint64_t vsctlr; /* Virtualization System control register. */ |
30 | + * Copyright (c) 2021 Xilinx Inc. | 22 | uint64_t cpacr_el1; /* Architectural feature access control register */ |
31 | + * SPDX-License-Identifier: GPL-2.0-or-later | 23 | uint64_t cptr_el[4]; /* ARMv8 feature trap registers */ |
32 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 24 | uint32_t c1_xscaleauxcr; /* XScale auxiliary control register. */ |
33 | + */ | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
34 | + | 26 | */ |
35 | +#ifndef XLNX_VERSAL_XRAMC_H | 27 | uint32_t *rbar[M_REG_NUM_BANKS]; |
36 | +#define XLNX_VERSAL_XRAMC_H | 28 | uint32_t *rlar[M_REG_NUM_BANKS]; |
37 | + | 29 | + uint32_t *hprbar; |
38 | +#include "hw/sysbus.h" | 30 | + uint32_t *hprlar; |
39 | +#include "hw/register.h" | 31 | uint32_t mair0[M_REG_NUM_BANKS]; |
40 | + | 32 | uint32_t mair1[M_REG_NUM_BANKS]; |
41 | +#define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc" | 33 | + uint32_t hprselr; |
42 | + | 34 | } pmsav8; |
43 | +#define XLNX_XRAM_CTRL(obj) \ | 35 | |
44 | + OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL) | 36 | /* v8M SAU */ |
45 | + | 37 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
46 | +REG32(XRAM_ERR_CTRL, 0x0) | 38 | bool has_mpu; |
47 | + FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1) | 39 | /* PMSAv7 MPU number of supported regions */ |
48 | + FIELD(XRAM_ERR_CTRL, PWR_ERR_RES, 2, 1) | 40 | uint32_t pmsav7_dregion; |
49 | + FIELD(XRAM_ERR_CTRL, PZ_ERR_RES, 1, 1) | 41 | + /* PMSAv8 MPU number of supported hyp regions */ |
50 | + FIELD(XRAM_ERR_CTRL, APB_ERR_RES, 0, 1) | 42 | + uint32_t pmsav8r_hdregion; |
51 | +REG32(XRAM_ISR, 0x4) | 43 | /* v8M SAU number of supported regions */ |
52 | + FIELD(XRAM_ISR, INV_APB, 0, 1) | 44 | uint32_t sau_sregion; |
53 | +REG32(XRAM_IMR, 0x8) | 45 | |
54 | + FIELD(XRAM_IMR, INV_APB, 0, 1) | 46 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
55 | +REG32(XRAM_IEN, 0xc) | 47 | index XXXXXXX..XXXXXXX 100644 |
56 | + FIELD(XRAM_IEN, INV_APB, 0, 1) | 48 | --- a/target/arm/cpu.c |
57 | +REG32(XRAM_IDS, 0x10) | 49 | +++ b/target/arm/cpu.c |
58 | + FIELD(XRAM_IDS, INV_APB, 0, 1) | 50 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) |
59 | +REG32(XRAM_ECC_CNTL, 0x14) | 51 | sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion); |
60 | + FIELD(XRAM_ECC_CNTL, FI_MODE, 2, 1) | 52 | } |
61 | + FIELD(XRAM_ECC_CNTL, DET_ONLY, 1, 1) | 53 | } |
62 | + FIELD(XRAM_ECC_CNTL, ECC_ON_OFF, 0, 1) | 54 | + |
63 | +REG32(XRAM_CLR_EXE, 0x18) | 55 | + if (cpu->pmsav8r_hdregion > 0) { |
64 | + FIELD(XRAM_CLR_EXE, MON_7, 7, 1) | 56 | + memset(env->pmsav8.hprbar, 0, |
65 | + FIELD(XRAM_CLR_EXE, MON_6, 6, 1) | 57 | + sizeof(*env->pmsav8.hprbar) * cpu->pmsav8r_hdregion); |
66 | + FIELD(XRAM_CLR_EXE, MON_5, 5, 1) | 58 | + memset(env->pmsav8.hprlar, 0, |
67 | + FIELD(XRAM_CLR_EXE, MON_4, 4, 1) | 59 | + sizeof(*env->pmsav8.hprlar) * cpu->pmsav8r_hdregion); |
68 | + FIELD(XRAM_CLR_EXE, MON_3, 3, 1) | 60 | + } |
69 | + FIELD(XRAM_CLR_EXE, MON_2, 2, 1) | 61 | + |
70 | + FIELD(XRAM_CLR_EXE, MON_1, 1, 1) | 62 | env->pmsav7.rnr[M_REG_NS] = 0; |
71 | + FIELD(XRAM_CLR_EXE, MON_0, 0, 1) | 63 | env->pmsav7.rnr[M_REG_S] = 0; |
72 | +REG32(XRAM_CE_FFA, 0x1c) | 64 | env->pmsav8.mair0[M_REG_NS] = 0; |
73 | + FIELD(XRAM_CE_FFA, ADDR, 0, 20) | 65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
74 | +REG32(XRAM_CE_FFD0, 0x20) | 66 | /* MPU can be configured out of a PMSA CPU either by setting has-mpu |
75 | +REG32(XRAM_CE_FFD1, 0x24) | 67 | * to false or by setting pmsav7-dregion to 0. |
76 | +REG32(XRAM_CE_FFD2, 0x28) | 68 | */ |
77 | +REG32(XRAM_CE_FFD3, 0x2c) | 69 | - if (!cpu->has_mpu) { |
78 | +REG32(XRAM_CE_FFE, 0x30) | 70 | - cpu->pmsav7_dregion = 0; |
79 | + FIELD(XRAM_CE_FFE, SYNDROME, 0, 16) | 71 | - } |
80 | +REG32(XRAM_UE_FFA, 0x34) | 72 | - if (cpu->pmsav7_dregion == 0) { |
81 | + FIELD(XRAM_UE_FFA, ADDR, 0, 20) | 73 | + if (!cpu->has_mpu || cpu->pmsav7_dregion == 0) { |
82 | +REG32(XRAM_UE_FFD0, 0x38) | 74 | cpu->has_mpu = false; |
83 | +REG32(XRAM_UE_FFD1, 0x3c) | 75 | + cpu->pmsav7_dregion = 0; |
84 | +REG32(XRAM_UE_FFD2, 0x40) | 76 | + cpu->pmsav8r_hdregion = 0; |
85 | +REG32(XRAM_UE_FFD3, 0x44) | 77 | } |
86 | +REG32(XRAM_UE_FFE, 0x48) | 78 | |
87 | + FIELD(XRAM_UE_FFE, SYNDROME, 0, 16) | 79 | if (arm_feature(env, ARM_FEATURE_PMSA) && |
88 | +REG32(XRAM_FI_D0, 0x4c) | 80 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
89 | +REG32(XRAM_FI_D1, 0x50) | 81 | env->pmsav7.dracr = g_new0(uint32_t, nr); |
90 | +REG32(XRAM_FI_D2, 0x54) | 82 | } |
91 | +REG32(XRAM_FI_D3, 0x58) | 83 | } |
92 | +REG32(XRAM_FI_SY, 0x5c) | 84 | + |
93 | + FIELD(XRAM_FI_SY, DATA, 0, 16) | 85 | + if (cpu->pmsav8r_hdregion > 0xff) { |
94 | +REG32(XRAM_RMW_UE_FFA, 0x70) | 86 | + error_setg(errp, "PMSAv8 MPU EL2 #regions invalid %" PRIu32, |
95 | + FIELD(XRAM_RMW_UE_FFA, ADDR, 0, 20) | 87 | + cpu->pmsav8r_hdregion); |
96 | +REG32(XRAM_FI_CNTR, 0x74) | 88 | + return; |
97 | + FIELD(XRAM_FI_CNTR, COUNT, 0, 24) | 89 | + } |
98 | +REG32(XRAM_IMP, 0x80) | 90 | + |
99 | + FIELD(XRAM_IMP, SIZE, 0, 4) | 91 | + if (cpu->pmsav8r_hdregion) { |
100 | +REG32(XRAM_PRDY_DBG, 0x84) | 92 | + env->pmsav8.hprbar = g_new0(uint32_t, |
101 | + FIELD(XRAM_PRDY_DBG, ISLAND3, 12, 4) | 93 | + cpu->pmsav8r_hdregion); |
102 | + FIELD(XRAM_PRDY_DBG, ISLAND2, 8, 4) | 94 | + env->pmsav8.hprlar = g_new0(uint32_t, |
103 | + FIELD(XRAM_PRDY_DBG, ISLAND1, 4, 4) | 95 | + cpu->pmsav8r_hdregion); |
104 | + FIELD(XRAM_PRDY_DBG, ISLAND0, 0, 4) | 96 | + } |
105 | +REG32(XRAM_SAFETY_CHK, 0xff8) | 97 | } |
106 | + | 98 | |
107 | +#define XRAM_CTRL_R_MAX (R_XRAM_SAFETY_CHK + 1) | 99 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { |
108 | + | 100 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
109 | +typedef struct XlnxXramCtrl { | 101 | index XXXXXXX..XXXXXXX 100644 |
110 | + SysBusDevice parent_obj; | 102 | --- a/target/arm/helper.c |
111 | + MemoryRegion ram; | 103 | +++ b/target/arm/helper.c |
112 | + qemu_irq irq; | 104 | @@ -XXX,XX +XXX,XX @@ static void pmsav7_rgnr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
113 | + | 105 | raw_write(env, ri, value); |
114 | + struct { | 106 | } |
115 | + uint64_t size; | 107 | |
116 | + unsigned int encoded_size; | 108 | +static void prbar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
117 | + } cfg; | 109 | + uint64_t value) |
118 | + | 110 | +{ |
119 | + RegisterInfoArray *reg_array; | 111 | + ARMCPU *cpu = env_archcpu(env); |
120 | + uint32_t regs[XRAM_CTRL_R_MAX]; | 112 | + |
121 | + RegisterInfo regs_info[XRAM_CTRL_R_MAX]; | 113 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
122 | +} XlnxXramCtrl; | 114 | + env->pmsav8.rbar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]] = value; |
123 | +#endif | 115 | +} |
124 | diff --git a/hw/misc/xlnx-versal-xramc.c b/hw/misc/xlnx-versal-xramc.c | 116 | + |
125 | new file mode 100644 | 117 | +static uint64_t prbar_read(CPUARMState *env, const ARMCPRegInfo *ri) |
126 | index XXXXXXX..XXXXXXX | 118 | +{ |
127 | --- /dev/null | 119 | + return env->pmsav8.rbar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]]; |
128 | +++ b/hw/misc/xlnx-versal-xramc.c | 120 | +} |
129 | @@ -XXX,XX +XXX,XX @@ | 121 | + |
130 | +/* | 122 | +static void prlar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
131 | + * QEMU model of the Xilinx XRAM Controller. | 123 | + uint64_t value) |
132 | + * | 124 | +{ |
133 | + * Copyright (c) 2021 Xilinx Inc. | 125 | + ARMCPU *cpu = env_archcpu(env); |
134 | + * SPDX-License-Identifier: GPL-2.0-or-later | 126 | + |
135 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 127 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
136 | + */ | 128 | + env->pmsav8.rlar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]] = value; |
137 | + | 129 | +} |
138 | +#include "qemu/osdep.h" | 130 | + |
139 | +#include "qemu/units.h" | 131 | +static uint64_t prlar_read(CPUARMState *env, const ARMCPRegInfo *ri) |
140 | +#include "qapi/error.h" | 132 | +{ |
141 | +#include "migration/vmstate.h" | 133 | + return env->pmsav8.rlar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]]; |
142 | +#include "hw/sysbus.h" | 134 | +} |
143 | +#include "hw/register.h" | 135 | + |
144 | +#include "hw/qdev-properties.h" | 136 | +static void prselr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
145 | +#include "hw/irq.h" | 137 | + uint64_t value) |
146 | +#include "hw/misc/xlnx-versal-xramc.h" | 138 | +{ |
147 | + | 139 | + ARMCPU *cpu = env_archcpu(env); |
148 | +#ifndef XLNX_XRAM_CTRL_ERR_DEBUG | 140 | + |
149 | +#define XLNX_XRAM_CTRL_ERR_DEBUG 0 | 141 | + /* |
150 | +#endif | 142 | + * Ignore writes that would select not implemented region. |
151 | + | 143 | + * This is architecturally UNPREDICTABLE. |
152 | +static void xram_update_irq(XlnxXramCtrl *s) | 144 | + */ |
153 | +{ | 145 | + if (value >= cpu->pmsav7_dregion) { |
154 | + bool pending = s->regs[R_XRAM_ISR] & ~s->regs[R_XRAM_IMR]; | 146 | + return; |
155 | + qemu_set_irq(s->irq, pending); | 147 | + } |
156 | +} | 148 | + |
157 | + | 149 | + env->pmsav7.rnr[M_REG_NS] = value; |
158 | +static void xram_isr_postw(RegisterInfo *reg, uint64_t val64) | 150 | +} |
159 | +{ | 151 | + |
160 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque); | 152 | +static void hprbar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
161 | + xram_update_irq(s); | 153 | + uint64_t value) |
162 | +} | 154 | +{ |
163 | + | 155 | + ARMCPU *cpu = env_archcpu(env); |
164 | +static uint64_t xram_ien_prew(RegisterInfo *reg, uint64_t val64) | 156 | + |
165 | +{ | 157 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
166 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque); | 158 | + env->pmsav8.hprbar[env->pmsav8.hprselr] = value; |
167 | + uint32_t val = val64; | 159 | +} |
168 | + | 160 | + |
169 | + s->regs[R_XRAM_IMR] &= ~val; | 161 | +static uint64_t hprbar_read(CPUARMState *env, const ARMCPRegInfo *ri) |
170 | + xram_update_irq(s); | 162 | +{ |
171 | + return 0; | 163 | + return env->pmsav8.hprbar[env->pmsav8.hprselr]; |
172 | +} | 164 | +} |
173 | + | 165 | + |
174 | +static uint64_t xram_ids_prew(RegisterInfo *reg, uint64_t val64) | 166 | +static void hprlar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
175 | +{ | 167 | + uint64_t value) |
176 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque); | 168 | +{ |
177 | + uint32_t val = val64; | 169 | + ARMCPU *cpu = env_archcpu(env); |
178 | + | 170 | + |
179 | + s->regs[R_XRAM_IMR] |= val; | 171 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
180 | + xram_update_irq(s); | 172 | + env->pmsav8.hprlar[env->pmsav8.hprselr] = value; |
181 | + return 0; | 173 | +} |
182 | +} | 174 | + |
183 | + | 175 | +static uint64_t hprlar_read(CPUARMState *env, const ARMCPRegInfo *ri) |
184 | +static const RegisterAccessInfo xram_ctrl_regs_info[] = { | 176 | +{ |
185 | + { .name = "XRAM_ERR_CTRL", .addr = A_XRAM_ERR_CTRL, | 177 | + return env->pmsav8.hprlar[env->pmsav8.hprselr]; |
186 | + .reset = 0xf, | 178 | +} |
187 | + .rsvd = 0xfffffff0, | 179 | + |
188 | + },{ .name = "XRAM_ISR", .addr = A_XRAM_ISR, | 180 | +static void hprenr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
189 | + .rsvd = 0xfffff800, | 181 | + uint64_t value) |
190 | + .w1c = 0x7ff, | 182 | +{ |
191 | + .post_write = xram_isr_postw, | 183 | + uint32_t n; |
192 | + },{ .name = "XRAM_IMR", .addr = A_XRAM_IMR, | 184 | + uint32_t bit; |
193 | + .reset = 0x7ff, | 185 | + ARMCPU *cpu = env_archcpu(env); |
194 | + .rsvd = 0xfffff800, | 186 | + |
195 | + .ro = 0x7ff, | 187 | + /* Ignore writes to unimplemented regions */ |
196 | + },{ .name = "XRAM_IEN", .addr = A_XRAM_IEN, | 188 | + int rmax = MIN(cpu->pmsav8r_hdregion, 32); |
197 | + .rsvd = 0xfffff800, | 189 | + value &= MAKE_64BIT_MASK(0, rmax); |
198 | + .pre_write = xram_ien_prew, | 190 | + |
199 | + },{ .name = "XRAM_IDS", .addr = A_XRAM_IDS, | 191 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
200 | + .rsvd = 0xfffff800, | 192 | + |
201 | + .pre_write = xram_ids_prew, | 193 | + /* Register alias is only valid for first 32 indexes */ |
202 | + },{ .name = "XRAM_ECC_CNTL", .addr = A_XRAM_ECC_CNTL, | 194 | + for (n = 0; n < rmax; ++n) { |
203 | + .rsvd = 0xfffffff8, | 195 | + bit = extract32(value, n, 1); |
204 | + },{ .name = "XRAM_CLR_EXE", .addr = A_XRAM_CLR_EXE, | 196 | + env->pmsav8.hprlar[n] = deposit32( |
205 | + .rsvd = 0xffffff00, | 197 | + env->pmsav8.hprlar[n], 0, 1, bit); |
206 | + },{ .name = "XRAM_CE_FFA", .addr = A_XRAM_CE_FFA, | 198 | + } |
207 | + .rsvd = 0xfff00000, | 199 | +} |
208 | + .ro = 0xfffff, | 200 | + |
209 | + },{ .name = "XRAM_CE_FFD0", .addr = A_XRAM_CE_FFD0, | 201 | +static uint64_t hprenr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
210 | + .ro = 0xffffffff, | 202 | +{ |
211 | + },{ .name = "XRAM_CE_FFD1", .addr = A_XRAM_CE_FFD1, | 203 | + uint32_t n; |
212 | + .ro = 0xffffffff, | 204 | + uint32_t result = 0x0; |
213 | + },{ .name = "XRAM_CE_FFD2", .addr = A_XRAM_CE_FFD2, | 205 | + ARMCPU *cpu = env_archcpu(env); |
214 | + .ro = 0xffffffff, | 206 | + |
215 | + },{ .name = "XRAM_CE_FFD3", .addr = A_XRAM_CE_FFD3, | 207 | + /* Register alias is only valid for first 32 indexes */ |
216 | + .ro = 0xffffffff, | 208 | + for (n = 0; n < MIN(cpu->pmsav8r_hdregion, 32); ++n) { |
217 | + },{ .name = "XRAM_CE_FFE", .addr = A_XRAM_CE_FFE, | 209 | + if (env->pmsav8.hprlar[n] & 0x1) { |
218 | + .rsvd = 0xffff0000, | 210 | + result |= (0x1 << n); |
219 | + .ro = 0xffff, | 211 | + } |
220 | + },{ .name = "XRAM_UE_FFA", .addr = A_XRAM_UE_FFA, | 212 | + } |
221 | + .rsvd = 0xfff00000, | 213 | + return result; |
222 | + .ro = 0xfffff, | 214 | +} |
223 | + },{ .name = "XRAM_UE_FFD0", .addr = A_XRAM_UE_FFD0, | 215 | + |
224 | + .ro = 0xffffffff, | 216 | +static void hprselr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
225 | + },{ .name = "XRAM_UE_FFD1", .addr = A_XRAM_UE_FFD1, | 217 | + uint64_t value) |
226 | + .ro = 0xffffffff, | 218 | +{ |
227 | + },{ .name = "XRAM_UE_FFD2", .addr = A_XRAM_UE_FFD2, | 219 | + ARMCPU *cpu = env_archcpu(env); |
228 | + .ro = 0xffffffff, | 220 | + |
229 | + },{ .name = "XRAM_UE_FFD3", .addr = A_XRAM_UE_FFD3, | 221 | + /* |
230 | + .ro = 0xffffffff, | 222 | + * Ignore writes that would select not implemented region. |
231 | + },{ .name = "XRAM_UE_FFE", .addr = A_XRAM_UE_FFE, | 223 | + * This is architecturally UNPREDICTABLE. |
232 | + .rsvd = 0xffff0000, | 224 | + */ |
233 | + .ro = 0xffff, | 225 | + if (value >= cpu->pmsav8r_hdregion) { |
234 | + },{ .name = "XRAM_FI_D0", .addr = A_XRAM_FI_D0, | 226 | + return; |
235 | + },{ .name = "XRAM_FI_D1", .addr = A_XRAM_FI_D1, | 227 | + } |
236 | + },{ .name = "XRAM_FI_D2", .addr = A_XRAM_FI_D2, | 228 | + |
237 | + },{ .name = "XRAM_FI_D3", .addr = A_XRAM_FI_D3, | 229 | + env->pmsav8.hprselr = value; |
238 | + },{ .name = "XRAM_FI_SY", .addr = A_XRAM_FI_SY, | 230 | +} |
239 | + .rsvd = 0xffff0000, | 231 | + |
240 | + },{ .name = "XRAM_RMW_UE_FFA", .addr = A_XRAM_RMW_UE_FFA, | 232 | +static void pmsav8r_regn_write(CPUARMState *env, const ARMCPRegInfo *ri, |
241 | + .rsvd = 0xfff00000, | 233 | + uint64_t value) |
242 | + .ro = 0xfffff, | 234 | +{ |
243 | + },{ .name = "XRAM_FI_CNTR", .addr = A_XRAM_FI_CNTR, | 235 | + ARMCPU *cpu = env_archcpu(env); |
244 | + .rsvd = 0xff000000, | 236 | + uint8_t index = (extract32(ri->opc0, 0, 1) << 4) | |
245 | + },{ .name = "XRAM_IMP", .addr = A_XRAM_IMP, | 237 | + (extract32(ri->crm, 0, 3) << 1) | extract32(ri->opc2, 2, 1); |
246 | + .reset = 0x4, | 238 | + |
247 | + .rsvd = 0xfffffff0, | 239 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
248 | + .ro = 0xf, | 240 | + |
249 | + },{ .name = "XRAM_PRDY_DBG", .addr = A_XRAM_PRDY_DBG, | 241 | + if (ri->opc1 & 4) { |
250 | + .reset = 0xffff, | 242 | + if (index >= cpu->pmsav8r_hdregion) { |
251 | + .rsvd = 0xffff0000, | 243 | + return; |
252 | + .ro = 0xffff, | 244 | + } |
253 | + },{ .name = "XRAM_SAFETY_CHK", .addr = A_XRAM_SAFETY_CHK, | 245 | + if (ri->opc2 & 0x1) { |
254 | + } | 246 | + env->pmsav8.hprlar[index] = value; |
247 | + } else { | ||
248 | + env->pmsav8.hprbar[index] = value; | ||
249 | + } | ||
250 | + } else { | ||
251 | + if (index >= cpu->pmsav7_dregion) { | ||
252 | + return; | ||
253 | + } | ||
254 | + if (ri->opc2 & 0x1) { | ||
255 | + env->pmsav8.rlar[M_REG_NS][index] = value; | ||
256 | + } else { | ||
257 | + env->pmsav8.rbar[M_REG_NS][index] = value; | ||
258 | + } | ||
259 | + } | ||
260 | +} | ||
261 | + | ||
262 | +static uint64_t pmsav8r_regn_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
263 | +{ | ||
264 | + ARMCPU *cpu = env_archcpu(env); | ||
265 | + uint8_t index = (extract32(ri->opc0, 0, 1) << 4) | | ||
266 | + (extract32(ri->crm, 0, 3) << 1) | extract32(ri->opc2, 2, 1); | ||
267 | + | ||
268 | + if (ri->opc1 & 4) { | ||
269 | + if (index >= cpu->pmsav8r_hdregion) { | ||
270 | + return 0x0; | ||
271 | + } | ||
272 | + if (ri->opc2 & 0x1) { | ||
273 | + return env->pmsav8.hprlar[index]; | ||
274 | + } else { | ||
275 | + return env->pmsav8.hprbar[index]; | ||
276 | + } | ||
277 | + } else { | ||
278 | + if (index >= cpu->pmsav7_dregion) { | ||
279 | + return 0x0; | ||
280 | + } | ||
281 | + if (ri->opc2 & 0x1) { | ||
282 | + return env->pmsav8.rlar[M_REG_NS][index]; | ||
283 | + } else { | ||
284 | + return env->pmsav8.rbar[M_REG_NS][index]; | ||
285 | + } | ||
286 | + } | ||
287 | +} | ||
288 | + | ||
289 | +static const ARMCPRegInfo pmsav8r_cp_reginfo[] = { | ||
290 | + { .name = "PRBAR", | ||
291 | + .cp = 15, .opc1 = 0, .crn = 6, .crm = 3, .opc2 = 0, | ||
292 | + .access = PL1_RW, .type = ARM_CP_NO_RAW, | ||
293 | + .accessfn = access_tvm_trvm, | ||
294 | + .readfn = prbar_read, .writefn = prbar_write }, | ||
295 | + { .name = "PRLAR", | ||
296 | + .cp = 15, .opc1 = 0, .crn = 6, .crm = 3, .opc2 = 1, | ||
297 | + .access = PL1_RW, .type = ARM_CP_NO_RAW, | ||
298 | + .accessfn = access_tvm_trvm, | ||
299 | + .readfn = prlar_read, .writefn = prlar_write }, | ||
300 | + { .name = "PRSELR", .resetvalue = 0, | ||
301 | + .cp = 15, .opc1 = 0, .crn = 6, .crm = 2, .opc2 = 1, | ||
302 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
303 | + .writefn = prselr_write, | ||
304 | + .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]) }, | ||
305 | + { .name = "HPRBAR", .resetvalue = 0, | ||
306 | + .cp = 15, .opc1 = 4, .crn = 6, .crm = 3, .opc2 = 0, | ||
307 | + .access = PL2_RW, .type = ARM_CP_NO_RAW, | ||
308 | + .readfn = hprbar_read, .writefn = hprbar_write }, | ||
309 | + { .name = "HPRLAR", | ||
310 | + .cp = 15, .opc1 = 4, .crn = 6, .crm = 3, .opc2 = 1, | ||
311 | + .access = PL2_RW, .type = ARM_CP_NO_RAW, | ||
312 | + .readfn = hprlar_read, .writefn = hprlar_write }, | ||
313 | + { .name = "HPRSELR", .resetvalue = 0, | ||
314 | + .cp = 15, .opc1 = 4, .crn = 6, .crm = 2, .opc2 = 1, | ||
315 | + .access = PL2_RW, | ||
316 | + .writefn = hprselr_write, | ||
317 | + .fieldoffset = offsetof(CPUARMState, pmsav8.hprselr) }, | ||
318 | + { .name = "HPRENR", | ||
319 | + .cp = 15, .opc1 = 4, .crn = 6, .crm = 1, .opc2 = 1, | ||
320 | + .access = PL2_RW, .type = ARM_CP_NO_RAW, | ||
321 | + .readfn = hprenr_read, .writefn = hprenr_write }, | ||
255 | +}; | 322 | +}; |
256 | + | 323 | + |
257 | +static void xram_ctrl_reset_enter(Object *obj, ResetType type) | 324 | static const ARMCPRegInfo pmsav7_cp_reginfo[] = { |
258 | +{ | 325 | /* Reset for all these registers is handled in arm_cpu_reset(), |
259 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | 326 | * because the PMSAv7 is also used by M-profile CPUs, which do |
260 | + unsigned int i; | 327 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
261 | + | 328 | .access = PL1_R, .type = ARM_CP_CONST, |
262 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | 329 | .resetvalue = cpu->pmsav7_dregion << 8 |
263 | + register_reset(&s->regs_info[i]); | 330 | }; |
264 | + } | 331 | + /* HMPUIR is specific to PMSA V8 */ |
265 | + | 332 | + ARMCPRegInfo id_hmpuir_reginfo = { |
266 | + ARRAY_FIELD_DP32(s->regs, XRAM_IMP, SIZE, s->cfg.encoded_size); | 333 | + .name = "HMPUIR", |
267 | +} | 334 | + .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 4, |
268 | + | 335 | + .access = PL2_R, .type = ARM_CP_CONST, |
269 | +static void xram_ctrl_reset_hold(Object *obj) | 336 | + .resetvalue = cpu->pmsav8r_hdregion |
270 | +{ | 337 | + }; |
271 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | 338 | static const ARMCPRegInfo crn0_wi_reginfo = { |
272 | + | 339 | .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, |
273 | + xram_update_irq(s); | 340 | .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, |
274 | +} | 341 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
275 | + | 342 | define_arm_cp_regs(cpu, id_cp_reginfo); |
276 | +static const MemoryRegionOps xram_ctrl_ops = { | 343 | if (!arm_feature(env, ARM_FEATURE_PMSA)) { |
277 | + .read = register_read_memory, | 344 | define_one_arm_cp_reg(cpu, &id_tlbtr_reginfo); |
278 | + .write = register_write_memory, | 345 | + } else if (arm_feature(env, ARM_FEATURE_PMSA) && |
279 | + .endianness = DEVICE_LITTLE_ENDIAN, | 346 | + arm_feature(env, ARM_FEATURE_V8)) { |
280 | + .valid = { | 347 | + uint32_t i = 0; |
281 | + .min_access_size = 4, | 348 | + char *tmp_string; |
282 | + .max_access_size = 4, | 349 | + |
350 | + define_one_arm_cp_reg(cpu, &id_mpuir_reginfo); | ||
351 | + define_one_arm_cp_reg(cpu, &id_hmpuir_reginfo); | ||
352 | + define_arm_cp_regs(cpu, pmsav8r_cp_reginfo); | ||
353 | + | ||
354 | + /* Register alias is only valid for first 32 indexes */ | ||
355 | + for (i = 0; i < MIN(cpu->pmsav7_dregion, 32); ++i) { | ||
356 | + uint8_t crm = 0b1000 | extract32(i, 1, 3); | ||
357 | + uint8_t opc1 = extract32(i, 4, 1); | ||
358 | + uint8_t opc2 = extract32(i, 0, 1) << 2; | ||
359 | + | ||
360 | + tmp_string = g_strdup_printf("PRBAR%u", i); | ||
361 | + ARMCPRegInfo tmp_prbarn_reginfo = { | ||
362 | + .name = tmp_string, .type = ARM_CP_ALIAS | ARM_CP_NO_RAW, | ||
363 | + .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2, | ||
364 | + .access = PL1_RW, .resetvalue = 0, | ||
365 | + .accessfn = access_tvm_trvm, | ||
366 | + .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read | ||
367 | + }; | ||
368 | + define_one_arm_cp_reg(cpu, &tmp_prbarn_reginfo); | ||
369 | + g_free(tmp_string); | ||
370 | + | ||
371 | + opc2 = extract32(i, 0, 1) << 2 | 0x1; | ||
372 | + tmp_string = g_strdup_printf("PRLAR%u", i); | ||
373 | + ARMCPRegInfo tmp_prlarn_reginfo = { | ||
374 | + .name = tmp_string, .type = ARM_CP_ALIAS | ARM_CP_NO_RAW, | ||
375 | + .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2, | ||
376 | + .access = PL1_RW, .resetvalue = 0, | ||
377 | + .accessfn = access_tvm_trvm, | ||
378 | + .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read | ||
379 | + }; | ||
380 | + define_one_arm_cp_reg(cpu, &tmp_prlarn_reginfo); | ||
381 | + g_free(tmp_string); | ||
382 | + } | ||
383 | + | ||
384 | + /* Register alias is only valid for first 32 indexes */ | ||
385 | + for (i = 0; i < MIN(cpu->pmsav8r_hdregion, 32); ++i) { | ||
386 | + uint8_t crm = 0b1000 | extract32(i, 1, 3); | ||
387 | + uint8_t opc1 = 0b100 | extract32(i, 4, 1); | ||
388 | + uint8_t opc2 = extract32(i, 0, 1) << 2; | ||
389 | + | ||
390 | + tmp_string = g_strdup_printf("HPRBAR%u", i); | ||
391 | + ARMCPRegInfo tmp_hprbarn_reginfo = { | ||
392 | + .name = tmp_string, | ||
393 | + .type = ARM_CP_NO_RAW, | ||
394 | + .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2, | ||
395 | + .access = PL2_RW, .resetvalue = 0, | ||
396 | + .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read | ||
397 | + }; | ||
398 | + define_one_arm_cp_reg(cpu, &tmp_hprbarn_reginfo); | ||
399 | + g_free(tmp_string); | ||
400 | + | ||
401 | + opc2 = extract32(i, 0, 1) << 2 | 0x1; | ||
402 | + tmp_string = g_strdup_printf("HPRLAR%u", i); | ||
403 | + ARMCPRegInfo tmp_hprlarn_reginfo = { | ||
404 | + .name = tmp_string, | ||
405 | + .type = ARM_CP_NO_RAW, | ||
406 | + .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2, | ||
407 | + .access = PL2_RW, .resetvalue = 0, | ||
408 | + .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read | ||
409 | + }; | ||
410 | + define_one_arm_cp_reg(cpu, &tmp_hprlarn_reginfo); | ||
411 | + g_free(tmp_string); | ||
412 | + } | ||
413 | } else if (arm_feature(env, ARM_FEATURE_V7)) { | ||
414 | define_one_arm_cp_reg(cpu, &id_mpuir_reginfo); | ||
415 | } | ||
416 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
417 | sctlr.type |= ARM_CP_SUPPRESS_TB_END; | ||
418 | } | ||
419 | define_one_arm_cp_reg(cpu, &sctlr); | ||
420 | + | ||
421 | + if (arm_feature(env, ARM_FEATURE_PMSA) && | ||
422 | + arm_feature(env, ARM_FEATURE_V8)) { | ||
423 | + ARMCPRegInfo vsctlr = { | ||
424 | + .name = "VSCTLR", .state = ARM_CP_STATE_AA32, | ||
425 | + .cp = 15, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, | ||
426 | + .access = PL2_RW, .resetvalue = 0x0, | ||
427 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.vsctlr), | ||
428 | + }; | ||
429 | + define_one_arm_cp_reg(cpu, &vsctlr); | ||
430 | + } | ||
431 | } | ||
432 | |||
433 | if (cpu_isar_feature(aa64_lor, cpu)) { | ||
434 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
435 | index XXXXXXX..XXXXXXX 100644 | ||
436 | --- a/target/arm/machine.c | ||
437 | +++ b/target/arm/machine.c | ||
438 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_needed(void *opaque) | ||
439 | arm_feature(env, ARM_FEATURE_V8); | ||
440 | } | ||
441 | |||
442 | +static bool pmsav8r_needed(void *opaque) | ||
443 | +{ | ||
444 | + ARMCPU *cpu = opaque; | ||
445 | + CPUARMState *env = &cpu->env; | ||
446 | + | ||
447 | + return arm_feature(env, ARM_FEATURE_PMSA) && | ||
448 | + arm_feature(env, ARM_FEATURE_V8) && | ||
449 | + !arm_feature(env, ARM_FEATURE_M); | ||
450 | +} | ||
451 | + | ||
452 | +static const VMStateDescription vmstate_pmsav8r = { | ||
453 | + .name = "cpu/pmsav8/pmsav8r", | ||
454 | + .version_id = 1, | ||
455 | + .minimum_version_id = 1, | ||
456 | + .needed = pmsav8r_needed, | ||
457 | + .fields = (VMStateField[]) { | ||
458 | + VMSTATE_VARRAY_UINT32(env.pmsav8.hprbar, ARMCPU, | ||
459 | + pmsav8r_hdregion, 0, vmstate_info_uint32, uint32_t), | ||
460 | + VMSTATE_VARRAY_UINT32(env.pmsav8.hprlar, ARMCPU, | ||
461 | + pmsav8r_hdregion, 0, vmstate_info_uint32, uint32_t), | ||
462 | + VMSTATE_END_OF_LIST() | ||
283 | + }, | 463 | + }, |
284 | +}; | 464 | +}; |
285 | + | 465 | + |
286 | +static void xram_ctrl_realize(DeviceState *dev, Error **errp) | 466 | static const VMStateDescription vmstate_pmsav8 = { |
287 | +{ | 467 | .name = "cpu/pmsav8", |
288 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 468 | .version_id = 1, |
289 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(dev); | 469 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pmsav8 = { |
290 | + | 470 | VMSTATE_UINT32(env.pmsav8.mair0[M_REG_NS], ARMCPU), |
291 | + switch (s->cfg.size) { | 471 | VMSTATE_UINT32(env.pmsav8.mair1[M_REG_NS], ARMCPU), |
292 | + case 64 * KiB: | 472 | VMSTATE_END_OF_LIST() |
293 | + s->cfg.encoded_size = 0; | 473 | + }, |
294 | + break; | 474 | + .subsections = (const VMStateDescription * []) { |
295 | + case 128 * KiB: | 475 | + &vmstate_pmsav8r, |
296 | + s->cfg.encoded_size = 1; | 476 | + NULL |
297 | + break; | 477 | } |
298 | + case 256 * KiB: | 478 | }; |
299 | + s->cfg.encoded_size = 2; | 479 | |
300 | + break; | ||
301 | + case 512 * KiB: | ||
302 | + s->cfg.encoded_size = 3; | ||
303 | + break; | ||
304 | + case 1 * MiB: | ||
305 | + s->cfg.encoded_size = 4; | ||
306 | + break; | ||
307 | + default: | ||
308 | + error_setg(errp, "Unsupported XRAM size %" PRId64, s->cfg.size); | ||
309 | + return; | ||
310 | + } | ||
311 | + | ||
312 | + memory_region_init_ram(&s->ram, OBJECT(s), | ||
313 | + object_get_canonical_path_component(OBJECT(s)), | ||
314 | + s->cfg.size, &error_fatal); | ||
315 | + sysbus_init_mmio(sbd, &s->ram); | ||
316 | +} | ||
317 | + | ||
318 | +static void xram_ctrl_init(Object *obj) | ||
319 | +{ | ||
320 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
321 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
322 | + | ||
323 | + s->reg_array = | ||
324 | + register_init_block32(DEVICE(obj), xram_ctrl_regs_info, | ||
325 | + ARRAY_SIZE(xram_ctrl_regs_info), | ||
326 | + s->regs_info, s->regs, | ||
327 | + &xram_ctrl_ops, | ||
328 | + XLNX_XRAM_CTRL_ERR_DEBUG, | ||
329 | + XRAM_CTRL_R_MAX * 4); | ||
330 | + sysbus_init_mmio(sbd, &s->reg_array->mem); | ||
331 | + sysbus_init_irq(sbd, &s->irq); | ||
332 | +} | ||
333 | + | ||
334 | +static void xram_ctrl_finalize(Object *obj) | ||
335 | +{ | ||
336 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
337 | + register_finalize_block(s->reg_array); | ||
338 | +} | ||
339 | + | ||
340 | +static const VMStateDescription vmstate_xram_ctrl = { | ||
341 | + .name = TYPE_XLNX_XRAM_CTRL, | ||
342 | + .version_id = 1, | ||
343 | + .minimum_version_id = 1, | ||
344 | + .fields = (VMStateField[]) { | ||
345 | + VMSTATE_UINT32_ARRAY(regs, XlnxXramCtrl, XRAM_CTRL_R_MAX), | ||
346 | + VMSTATE_END_OF_LIST(), | ||
347 | + } | ||
348 | +}; | ||
349 | + | ||
350 | +static Property xram_ctrl_properties[] = { | ||
351 | + DEFINE_PROP_UINT64("size", XlnxXramCtrl, cfg.size, 1 * MiB), | ||
352 | + DEFINE_PROP_END_OF_LIST(), | ||
353 | +}; | ||
354 | + | ||
355 | +static void xram_ctrl_class_init(ObjectClass *klass, void *data) | ||
356 | +{ | ||
357 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
358 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
359 | + | ||
360 | + dc->realize = xram_ctrl_realize; | ||
361 | + dc->vmsd = &vmstate_xram_ctrl; | ||
362 | + device_class_set_props(dc, xram_ctrl_properties); | ||
363 | + | ||
364 | + rc->phases.enter = xram_ctrl_reset_enter; | ||
365 | + rc->phases.hold = xram_ctrl_reset_hold; | ||
366 | +} | ||
367 | + | ||
368 | +static const TypeInfo xram_ctrl_info = { | ||
369 | + .name = TYPE_XLNX_XRAM_CTRL, | ||
370 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
371 | + .instance_size = sizeof(XlnxXramCtrl), | ||
372 | + .class_init = xram_ctrl_class_init, | ||
373 | + .instance_init = xram_ctrl_init, | ||
374 | + .instance_finalize = xram_ctrl_finalize, | ||
375 | +}; | ||
376 | + | ||
377 | +static void xram_ctrl_register_types(void) | ||
378 | +{ | ||
379 | + type_register_static(&xram_ctrl_info); | ||
380 | +} | ||
381 | + | ||
382 | +type_init(xram_ctrl_register_types) | ||
383 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
384 | index XXXXXXX..XXXXXXX 100644 | ||
385 | --- a/hw/misc/meson.build | ||
386 | +++ b/hw/misc/meson.build | ||
387 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
388 | )) | ||
389 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | ||
390 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) | ||
391 | +softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-xramc.c')) | ||
392 | softmmu_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_syscfg.c')) | ||
393 | softmmu_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_syscfg.c')) | ||
394 | softmmu_ss.add(when: 'CONFIG_STM32F4XX_EXTI', if_true: files('stm32f4xx_exti.c')) | ||
395 | -- | 480 | -- |
396 | 2.20.1 | 481 | 2.25.1 |
397 | 482 | ||
398 | 483 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Currently the emulated EMAC for sun8i always traverses the transmit queue | 3 | Add PMSAv8r translation. |
4 | from the head when transferring packets. It searches for a list of consecutive | 4 | |
5 | descriptors whichs are flagged as ready for processing and transmits their payloads | 5 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
6 | accordingly. The controller stops processing once it finds a descriptor that is not | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | marked ready. | 7 | Message-id: 20221206102504.165775-7-tobias.roehmel@rwth-aachen.de |
8 | |||
9 | While the above behaviour works in most situations, it is not the same as the actual | ||
10 | EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep track | ||
11 | of the last position in the transmit queue and continues processing from that position | ||
12 | when software triggers the start of DMA processing. The currently emulated behaviour can | ||
13 | lead to packet loss on transmit when software fills the transmit queue with ready | ||
14 | descriptors that overlap the tail of the circular list. | ||
15 | |||
16 | This commit modifies the emulated EMAC for sun8i such that it processes | ||
17 | the transmit queue using the TX_CUR_DESC register in the same way as hardware. | ||
18 | |||
19 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20210310195820.21950-2-nieklinnenbank@gmail.com | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | --- | 9 | --- |
24 | hw/net/allwinner-sun8i-emac.c | 62 +++++++++++++++++++---------------- | 10 | target/arm/ptw.c | 126 ++++++++++++++++++++++++++++++++++++++--------- |
25 | 1 file changed, 34 insertions(+), 28 deletions(-) | 11 | 1 file changed, 104 insertions(+), 22 deletions(-) |
26 | 12 | ||
27 | diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c | 13 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
28 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/net/allwinner-sun8i-emac.c | 15 | --- a/target/arm/ptw.c |
30 | +++ b/hw/net/allwinner-sun8i-emac.c | 16 | +++ b/target/arm/ptw.c |
31 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s) | 17 | @@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, |
32 | qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0); | 18 | |
19 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
20 | return env->v7m.mpu_ctrl[is_secure] & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; | ||
21 | - } else { | ||
22 | - return regime_sctlr(env, mmu_idx) & SCTLR_BR; | ||
23 | } | ||
24 | + | ||
25 | + if (mmu_idx == ARMMMUIdx_Stage2) { | ||
26 | + return false; | ||
27 | + } | ||
28 | + | ||
29 | + return regime_sctlr(env, mmu_idx) & SCTLR_BR; | ||
33 | } | 30 | } |
34 | 31 | ||
35 | -static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s, | 32 | static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, |
36 | - FrameDescriptor *desc, | 33 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, |
37 | - size_t min_size) | 34 | return !(result->f.prot & (1 << access_type)); |
38 | +static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc, | ||
39 | + size_t min_buf_size) | ||
40 | { | ||
41 | - uint32_t paddr = desc->next; | ||
42 | - | ||
43 | - dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc)); | ||
44 | - | ||
45 | - if ((desc->status & DESC_STATUS_CTL) && | ||
46 | - (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) { | ||
47 | - return paddr; | ||
48 | - } else { | ||
49 | - return 0; | ||
50 | - } | ||
51 | + return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 || | ||
52 | + (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size); | ||
53 | } | 35 | } |
54 | 36 | ||
55 | -static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s, | 37 | +static uint32_t *regime_rbar(CPUARMState *env, ARMMMUIdx mmu_idx, |
56 | - FrameDescriptor *desc, | 38 | + uint32_t secure) |
57 | - uint32_t start_addr, | ||
58 | - size_t min_size) | ||
59 | +static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s, | ||
60 | + FrameDescriptor *desc, | ||
61 | + uint32_t phys_addr) | ||
62 | +{ | 39 | +{ |
63 | + dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc)); | 40 | + if (regime_el(env, mmu_idx) == 2) { |
41 | + return env->pmsav8.hprbar; | ||
42 | + } else { | ||
43 | + return env->pmsav8.rbar[secure]; | ||
44 | + } | ||
64 | +} | 45 | +} |
65 | + | 46 | + |
66 | +static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s, | 47 | +static uint32_t *regime_rlar(CPUARMState *env, ARMMMUIdx mmu_idx, |
67 | + FrameDescriptor *desc) | 48 | + uint32_t secure) |
68 | +{ | 49 | +{ |
69 | + const uint32_t nxt = desc->next; | 50 | + if (regime_el(env, mmu_idx) == 2) { |
70 | + allwinner_sun8i_emac_get_desc(s, desc, nxt); | 51 | + return env->pmsav8.hprlar; |
71 | + return nxt; | 52 | + } else { |
53 | + return env->pmsav8.rlar[secure]; | ||
54 | + } | ||
72 | +} | 55 | +} |
73 | + | 56 | + |
74 | +static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s, | 57 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
75 | + FrameDescriptor *desc, | 58 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
76 | + uint32_t start_addr, | 59 | bool secure, GetPhysAddrResult *result, |
77 | + size_t min_size) | 60 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
78 | { | 61 | bool hit = false; |
79 | uint32_t desc_addr = start_addr; | 62 | uint32_t addr_page_base = address & TARGET_PAGE_MASK; |
80 | 63 | uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); | |
81 | /* Note that the list is a cycle. Last entry points back to the head. */ | 64 | + int region_counter; |
82 | while (desc_addr != 0) { | 65 | + |
83 | - dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); | 66 | + if (regime_el(env, mmu_idx) == 2) { |
84 | + allwinner_sun8i_emac_get_desc(s, desc, desc_addr); | 67 | + region_counter = cpu->pmsav8r_hdregion; |
85 | 68 | + } else { | |
86 | - if ((desc->status & DESC_STATUS_CTL) && | 69 | + region_counter = cpu->pmsav7_dregion; |
87 | - (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) { | 70 | + } |
88 | + if (allwinner_sun8i_emac_desc_owned(desc, min_size)) { | 71 | |
89 | return desc_addr; | 72 | result->f.lg_page_size = TARGET_PAGE_BITS; |
90 | } else if (desc->next == start_addr) { | 73 | result->f.phys_addr = address; |
91 | break; | 74 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
92 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s, | 75 | *mregion = -1; |
93 | FrameDescriptor *desc, | 76 | } |
94 | size_t min_size) | 77 | |
95 | { | 78 | + if (mmu_idx == ARMMMUIdx_Stage2) { |
96 | - return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size); | 79 | + fi->stage2 = true; |
97 | + return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size); | 80 | + } |
81 | + | ||
82 | /* | ||
83 | * Unlike the ARM ARM pseudocode, we don't need to check whether this | ||
84 | * was an exception vector read from the vector table (which is always | ||
85 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
86 | hit = true; | ||
87 | } | ||
88 | |||
89 | - for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { | ||
90 | + uint32_t bitmask; | ||
91 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
92 | + bitmask = 0x1f; | ||
93 | + } else { | ||
94 | + bitmask = 0x3f; | ||
95 | + fi->level = 0; | ||
96 | + } | ||
97 | + | ||
98 | + for (n = region_counter - 1; n >= 0; n--) { | ||
99 | /* region search */ | ||
100 | /* | ||
101 | - * Note that the base address is bits [31:5] from the register | ||
102 | - * with bits [4:0] all zeroes, but the limit address is bits | ||
103 | - * [31:5] from the register with bits [4:0] all ones. | ||
104 | + * Note that the base address is bits [31:x] from the register | ||
105 | + * with bits [x-1:0] all zeroes, but the limit address is bits | ||
106 | + * [31:x] from the register with bits [x:0] all ones. Where x is | ||
107 | + * 5 for Cortex-M and 6 for Cortex-R | ||
108 | */ | ||
109 | - uint32_t base = env->pmsav8.rbar[secure][n] & ~0x1f; | ||
110 | - uint32_t limit = env->pmsav8.rlar[secure][n] | 0x1f; | ||
111 | + uint32_t base = regime_rbar(env, mmu_idx, secure)[n] & ~bitmask; | ||
112 | + uint32_t limit = regime_rlar(env, mmu_idx, secure)[n] | bitmask; | ||
113 | |||
114 | - if (!(env->pmsav8.rlar[secure][n] & 0x1)) { | ||
115 | + if (!(regime_rlar(env, mmu_idx, secure)[n] & 0x1)) { | ||
116 | /* Region disabled */ | ||
117 | continue; | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
120 | * PMSAv7 where highest-numbered-region wins) | ||
121 | */ | ||
122 | fi->type = ARMFault_Permission; | ||
123 | - fi->level = 1; | ||
124 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
125 | + fi->level = 1; | ||
126 | + } | ||
127 | return true; | ||
128 | } | ||
129 | |||
130 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
131 | } | ||
132 | |||
133 | if (!hit) { | ||
134 | - /* background fault */ | ||
135 | - fi->type = ARMFault_Background; | ||
136 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
137 | + fi->type = ARMFault_Background; | ||
138 | + } else { | ||
139 | + fi->type = ARMFault_Permission; | ||
140 | + } | ||
141 | return true; | ||
142 | } | ||
143 | |||
144 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
145 | /* hit using the background region */ | ||
146 | get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->f.prot); | ||
147 | } else { | ||
148 | - uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); | ||
149 | - uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); | ||
150 | + uint32_t matched_rbar = regime_rbar(env, mmu_idx, secure)[matchregion]; | ||
151 | + uint32_t matched_rlar = regime_rlar(env, mmu_idx, secure)[matchregion]; | ||
152 | + uint32_t ap = extract32(matched_rbar, 1, 2); | ||
153 | + uint32_t xn = extract32(matched_rbar, 0, 1); | ||
154 | bool pxn = false; | ||
155 | |||
156 | if (arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
157 | - pxn = extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); | ||
158 | + pxn = extract32(matched_rlar, 4, 1); | ||
159 | } | ||
160 | |||
161 | if (m_is_system_region(env, address)) { | ||
162 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
163 | xn = 1; | ||
164 | } | ||
165 | |||
166 | - result->f.prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | ||
167 | + if (regime_el(env, mmu_idx) == 2) { | ||
168 | + result->f.prot = simple_ap_to_rw_prot_is_user(ap, | ||
169 | + mmu_idx != ARMMMUIdx_E2); | ||
170 | + } else { | ||
171 | + result->f.prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | ||
172 | + } | ||
173 | + | ||
174 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
175 | + uint8_t attrindx = extract32(matched_rlar, 1, 3); | ||
176 | + uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; | ||
177 | + uint8_t sh = extract32(matched_rlar, 3, 2); | ||
178 | + | ||
179 | + if (regime_sctlr(env, mmu_idx) & SCTLR_WXN && | ||
180 | + result->f.prot & PAGE_WRITE && mmu_idx != ARMMMUIdx_Stage2) { | ||
181 | + xn = 0x1; | ||
182 | + } | ||
183 | + | ||
184 | + if ((regime_el(env, mmu_idx) == 1) && | ||
185 | + regime_sctlr(env, mmu_idx) & SCTLR_UWXN && ap == 0x1) { | ||
186 | + pxn = 0x1; | ||
187 | + } | ||
188 | + | ||
189 | + result->cacheattrs.is_s2_format = false; | ||
190 | + result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); | ||
191 | + result->cacheattrs.shareability = sh; | ||
192 | + } | ||
193 | + | ||
194 | if (result->f.prot && !xn && !(pxn && !is_user)) { | ||
195 | result->f.prot |= PAGE_EXEC; | ||
196 | } | ||
197 | - /* | ||
198 | - * We don't need to look the attribute up in the MAIR0/MAIR1 | ||
199 | - * registers because that only tells us about cacheability. | ||
200 | - */ | ||
201 | + | ||
202 | if (mregion) { | ||
203 | *mregion = matchregion; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | fi->type = ARMFault_Permission; | ||
208 | - fi->level = 1; | ||
209 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
210 | + fi->level = 1; | ||
211 | + } | ||
212 | return !(result->f.prot & (1 << access_type)); | ||
98 | } | 213 | } |
99 | 214 | ||
100 | static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s, | 215 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
101 | - FrameDescriptor *desc, | 216 | cacheattrs1 = result->cacheattrs; |
102 | - size_t min_size) | 217 | memset(result, 0, sizeof(*result)); |
103 | + FrameDescriptor *desc) | 218 | |
104 | { | 219 | - ret = get_phys_addr_lpae(env, ptw, ipa, access_type, is_el0, result, fi); |
105 | - return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size); | 220 | + if (arm_feature(env, ARM_FEATURE_PMSA)) { |
106 | + allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr); | 221 | + ret = get_phys_addr_pmsav8(env, ipa, access_type, |
107 | + return s->tx_desc_curr; | 222 | + ptw->in_mmu_idx, is_secure, result, fi); |
108 | } | 223 | + } else { |
109 | 224 | + ret = get_phys_addr_lpae(env, ptw, ipa, access_type, | |
110 | static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s, | 225 | + is_el0, result, fi); |
111 | @@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc, | 226 | + } |
112 | bytes_left -= desc_bytes; | 227 | fi->s2addr = ipa; |
113 | 228 | ||
114 | /* Move to the next descriptor */ | 229 | /* Combine the S1 and S2 perms. */ |
115 | - s->rx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 64); | ||
116 | + s->rx_desc_curr = allwinner_sun8i_emac_find_desc(s, &desc, desc.next, | ||
117 | + AW_SUN8I_EMAC_MIN_PKT_SZ); | ||
118 | if (!s->rx_desc_curr) { | ||
119 | /* Not enough buffer space available */ | ||
120 | s->int_sta |= INT_STA_RX_BUF_UA; | ||
121 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) | ||
122 | size_t transmitted = 0; | ||
123 | static uint8_t packet_buf[2048]; | ||
124 | |||
125 | - s->tx_desc_curr = allwinner_sun8i_emac_tx_desc(s, &desc, 0); | ||
126 | + s->tx_desc_curr = allwinner_sun8i_emac_tx_desc(s, &desc); | ||
127 | |||
128 | /* Read all transmit descriptors */ | ||
129 | - while (s->tx_desc_curr != 0) { | ||
130 | + while (allwinner_sun8i_emac_desc_owned(&desc, 0)) { | ||
131 | |||
132 | /* Read from physical memory into packet buffer */ | ||
133 | bytes = desc.status2 & DESC_STATUS2_BUF_SIZE_MASK; | ||
134 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) | ||
135 | packet_bytes = 0; | ||
136 | transmitted++; | ||
137 | } | ||
138 | - s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 0); | ||
139 | + s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc); | ||
140 | } | ||
141 | |||
142 | /* Raise transmit completed interrupt */ | ||
143 | -- | 230 | -- |
144 | 2.20.1 | 231 | 2.25.1 |
145 | 232 | ||
146 | 233 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds testing of PWM fan RPMs in the existing npcm7xx pwm | 3 | All constants are taken from the ARM Cortex-R52 Processor TRM Revision: r1p3 |
4 | test. It tests whether the MFT module can measure correct fan values | ||
5 | for a PWM fan in NPCM7XX boards. | ||
6 | 4 | ||
7 | Reviewed-by: Doug Evans <dje@google.com> | 5 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
8 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
9 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20210311180855.149764-6-wuhaotsh@google.com | 7 | Message-id: 20221206102504.165775-8-tobias.roehmel@rwth-aachen.de |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++++++++++++++++++++++- | 10 | target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++ |
15 | 1 file changed, 199 insertions(+), 6 deletions(-) | 11 | 1 file changed, 42 insertions(+) |
16 | 12 | ||
17 | diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c | 13 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/qtest/npcm7xx_pwm-test.c | 15 | --- a/target/arm/cpu_tcg.c |
20 | +++ b/tests/qtest/npcm7xx_pwm-test.c | 16 | +++ b/target/arm/cpu_tcg.c |
21 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) |
22 | #define PLL_FBDV(rv) extract32((rv), 16, 12) | 18 | define_arm_cp_regs(cpu, cortexr5_cp_reginfo); |
23 | #define PLL_OTDV1(rv) extract32((rv), 8, 3) | 19 | } |
24 | #define PLL_OTDV2(rv) extract32((rv), 13, 3) | 20 | |
25 | +#define APB4CKDIV(rv) extract32((rv), 30, 2) | 21 | +static void cortex_r52_initfn(Object *obj) |
26 | #define APB3CKDIV(rv) extract32((rv), 28, 2) | 22 | +{ |
27 | #define CLK2CKDIV(rv) extract32((rv), 0, 1) | 23 | + ARMCPU *cpu = ARM_CPU(obj); |
28 | #define CLK4CKDIV(rv) extract32((rv), 26, 2) | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | |||
31 | #define MAX_DUTY 1000000 | ||
32 | |||
33 | +/* MFT (PWM fan) related */ | ||
34 | +#define MFT_BA(n) (0xf0180000 + ((n) * 0x1000)) | ||
35 | +#define MFT_IRQ(n) (96 + (n)) | ||
36 | +#define MFT_CNT1 0x00 | ||
37 | +#define MFT_CRA 0x02 | ||
38 | +#define MFT_CRB 0x04 | ||
39 | +#define MFT_CNT2 0x06 | ||
40 | +#define MFT_PRSC 0x08 | ||
41 | +#define MFT_CKC 0x0a | ||
42 | +#define MFT_MCTRL 0x0c | ||
43 | +#define MFT_ICTRL 0x0e | ||
44 | +#define MFT_ICLR 0x10 | ||
45 | +#define MFT_IEN 0x12 | ||
46 | +#define MFT_CPA 0x14 | ||
47 | +#define MFT_CPB 0x16 | ||
48 | +#define MFT_CPCFG 0x18 | ||
49 | +#define MFT_INASEL 0x1a | ||
50 | +#define MFT_INBSEL 0x1c | ||
51 | + | 24 | + |
52 | +#define MFT_MCTRL_ALL 0x64 | 25 | + set_feature(&cpu->env, ARM_FEATURE_V8); |
53 | +#define MFT_ICLR_ALL 0x3f | 26 | + set_feature(&cpu->env, ARM_FEATURE_EL2); |
54 | +#define MFT_IEN_ALL 0x3f | 27 | + set_feature(&cpu->env, ARM_FEATURE_PMSA); |
55 | +#define MFT_CPCFG_EQ_MODE 0x44 | 28 | + set_feature(&cpu->env, ARM_FEATURE_NEON); |
29 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
30 | + cpu->midr = 0x411fd133; /* r1p3 */ | ||
31 | + cpu->revidr = 0x00000000; | ||
32 | + cpu->reset_fpsid = 0x41034023; | ||
33 | + cpu->isar.mvfr0 = 0x10110222; | ||
34 | + cpu->isar.mvfr1 = 0x12111111; | ||
35 | + cpu->isar.mvfr2 = 0x00000043; | ||
36 | + cpu->ctr = 0x8144c004; | ||
37 | + cpu->reset_sctlr = 0x30c50838; | ||
38 | + cpu->isar.id_pfr0 = 0x00000131; | ||
39 | + cpu->isar.id_pfr1 = 0x10111001; | ||
40 | + cpu->isar.id_dfr0 = 0x03010006; | ||
41 | + cpu->id_afr0 = 0x00000000; | ||
42 | + cpu->isar.id_mmfr0 = 0x00211040; | ||
43 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
44 | + cpu->isar.id_mmfr2 = 0x01200000; | ||
45 | + cpu->isar.id_mmfr3 = 0xf0102211; | ||
46 | + cpu->isar.id_mmfr4 = 0x00000010; | ||
47 | + cpu->isar.id_isar0 = 0x02101110; | ||
48 | + cpu->isar.id_isar1 = 0x13112111; | ||
49 | + cpu->isar.id_isar2 = 0x21232142; | ||
50 | + cpu->isar.id_isar3 = 0x01112131; | ||
51 | + cpu->isar.id_isar4 = 0x00010142; | ||
52 | + cpu->isar.id_isar5 = 0x00010001; | ||
53 | + cpu->isar.dbgdidr = 0x77168000; | ||
54 | + cpu->clidr = (1 << 27) | (1 << 24) | 0x3; | ||
55 | + cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ | ||
56 | + cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ | ||
56 | + | 57 | + |
57 | +#define MFT_CKC_C2CSEL BIT(3) | 58 | + cpu->pmsav7_dregion = 16; |
58 | +#define MFT_CKC_C1CSEL BIT(0) | 59 | + cpu->pmsav8r_hdregion = 16; |
59 | + | ||
60 | +#define MFT_ICTRL_TFPND BIT(5) | ||
61 | +#define MFT_ICTRL_TEPND BIT(4) | ||
62 | +#define MFT_ICTRL_TDPND BIT(3) | ||
63 | +#define MFT_ICTRL_TCPND BIT(2) | ||
64 | +#define MFT_ICTRL_TBPND BIT(1) | ||
65 | +#define MFT_ICTRL_TAPND BIT(0) | ||
66 | + | ||
67 | +#define MFT_MAX_CNT 0xffff | ||
68 | +#define MFT_TIMEOUT 0x5000 | ||
69 | + | ||
70 | +#define DEFAULT_RPM 19800 | ||
71 | +#define DEFAULT_PRSC 255 | ||
72 | +#define MFT_PULSE_PER_REVOLUTION 2 | ||
73 | + | ||
74 | +#define MAX_ERROR 1 | ||
75 | + | ||
76 | typedef struct PWMModule { | ||
77 | int irq; | ||
78 | uint64_t base_addr; | ||
79 | @@ -XXX,XX +XXX,XX @@ static uint64_t pwm_get_duty(QTestState *qts, int module_index, int pwm_index) | ||
80 | return pwm_qom_get(qts, path, name); | ||
81 | } | ||
82 | |||
83 | +static void mft_qom_set(QTestState *qts, int index, const char *name, | ||
84 | + uint32_t value) | ||
85 | +{ | ||
86 | + QDict *response; | ||
87 | + char *path = g_strdup_printf("/machine/soc/mft[%d]", index); | ||
88 | + | ||
89 | + g_test_message("Setting properties %s of mft[%d] with value %u", | ||
90 | + name, index, value); | ||
91 | + response = qtest_qmp(qts, "{ 'execute': 'qom-set'," | ||
92 | + " 'arguments': { 'path': %s, " | ||
93 | + " 'property': %s, 'value': %u}}", | ||
94 | + path, name, value); | ||
95 | + /* The qom set message returns successfully. */ | ||
96 | + g_assert_true(qdict_haskey(response, "return")); | ||
97 | +} | 60 | +} |
98 | + | 61 | + |
99 | static uint32_t get_pll(uint32_t con) | 62 | static void cortex_r5f_initfn(Object *obj) |
100 | { | 63 | { |
101 | return REF_HZ * PLL_FBDV(con) / (PLL_INDV(con) * PLL_OTDV1(con) | 64 | ARMCPU *cpu = ARM_CPU(obj); |
102 | * PLL_OTDV2(con)); | 65 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { |
103 | } | 66 | .class_init = arm_v7m_class_init }, |
104 | 67 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | |
105 | -static uint64_t read_pclk(QTestState *qts) | 68 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, |
106 | +static uint64_t read_pclk(QTestState *qts, bool mft) | 69 | + { .name = "cortex-r52", .initfn = cortex_r52_initfn }, |
107 | { | 70 | { .name = "ti925t", .initfn = ti925t_initfn }, |
108 | uint64_t freq = REF_HZ; | 71 | { .name = "sa1100", .initfn = sa1100_initfn }, |
109 | uint32_t clksel = qtest_readl(qts, CLK_BA + CLKSEL); | 72 | { .name = "sa1110", .initfn = sa1110_initfn }, |
110 | uint32_t pllcon; | ||
111 | uint32_t clkdiv1 = qtest_readl(qts, CLK_BA + CLKDIV1); | ||
112 | uint32_t clkdiv2 = qtest_readl(qts, CLK_BA + CLKDIV2); | ||
113 | + uint32_t apbdiv = mft ? APB4CKDIV(clkdiv2) : APB3CKDIV(clkdiv2); | ||
114 | |||
115 | switch (CPUCKSEL(clksel)) { | ||
116 | case 0: | ||
117 | @@ -XXX,XX +XXX,XX @@ static uint64_t read_pclk(QTestState *qts) | ||
118 | g_assert_not_reached(); | ||
119 | } | ||
120 | |||
121 | - freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + APB3CKDIV(clkdiv2)); | ||
122 | + freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + apbdiv); | ||
123 | |||
124 | return freq; | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static uint32_t pwm_selector(uint32_t csr) | ||
127 | static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr, | ||
128 | uint32_t cnr) | ||
129 | { | ||
130 | - return read_pclk(qts) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1)); | ||
131 | + return read_pclk(qts, false) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1)); | ||
132 | } | ||
133 | |||
134 | static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) | ||
135 | @@ -XXX,XX +XXX,XX @@ static void pwm_write(QTestState *qts, const TestData *td, unsigned offset, | ||
136 | qtest_writel(qts, td->module->base_addr + offset, value); | ||
137 | } | ||
138 | |||
139 | +static uint8_t mft_readb(QTestState *qts, int index, unsigned offset) | ||
140 | +{ | ||
141 | + return qtest_readb(qts, MFT_BA(index) + offset); | ||
142 | +} | ||
143 | + | ||
144 | +static uint16_t mft_readw(QTestState *qts, int index, unsigned offset) | ||
145 | +{ | ||
146 | + return qtest_readw(qts, MFT_BA(index) + offset); | ||
147 | +} | ||
148 | + | ||
149 | +static void mft_writeb(QTestState *qts, int index, unsigned offset, | ||
150 | + uint8_t value) | ||
151 | +{ | ||
152 | + qtest_writeb(qts, MFT_BA(index) + offset, value); | ||
153 | +} | ||
154 | + | ||
155 | +static void mft_writew(QTestState *qts, int index, unsigned offset, | ||
156 | + uint16_t value) | ||
157 | +{ | ||
158 | + return qtest_writew(qts, MFT_BA(index) + offset, value); | ||
159 | +} | ||
160 | + | ||
161 | static uint32_t pwm_read_ppr(QTestState *qts, const TestData *td) | ||
162 | { | ||
163 | return extract32(pwm_read(qts, td, PPR), ppr_base[pwm_index(td->pwm)], 8); | ||
164 | @@ -XXX,XX +XXX,XX @@ static void pwm_write_cmr(QTestState *qts, const TestData *td, uint32_t value) | ||
165 | pwm_write(qts, td, td->pwm->cmr_offset, value); | ||
166 | } | ||
167 | |||
168 | +static int mft_compute_index(const TestData *td) | ||
169 | +{ | ||
170 | + int index = pwm_module_index(td->module) * ARRAY_SIZE(pwm_list) + | ||
171 | + pwm_index(td->pwm); | ||
172 | + | ||
173 | + g_assert_cmpint(index, <, | ||
174 | + ARRAY_SIZE(pwm_module_list) * ARRAY_SIZE(pwm_list)); | ||
175 | + | ||
176 | + return index; | ||
177 | +} | ||
178 | + | ||
179 | +static void mft_reset_counters(QTestState *qts, int index) | ||
180 | +{ | ||
181 | + mft_writew(qts, index, MFT_CNT1, MFT_MAX_CNT); | ||
182 | + mft_writew(qts, index, MFT_CNT2, MFT_MAX_CNT); | ||
183 | + mft_writew(qts, index, MFT_CRA, MFT_MAX_CNT); | ||
184 | + mft_writew(qts, index, MFT_CRB, MFT_MAX_CNT); | ||
185 | + mft_writew(qts, index, MFT_CPA, MFT_MAX_CNT - MFT_TIMEOUT); | ||
186 | + mft_writew(qts, index, MFT_CPB, MFT_MAX_CNT - MFT_TIMEOUT); | ||
187 | +} | ||
188 | + | ||
189 | +static void mft_init(QTestState *qts, const TestData *td) | ||
190 | +{ | ||
191 | + int index = mft_compute_index(td); | ||
192 | + | ||
193 | + /* Enable everything */ | ||
194 | + mft_writeb(qts, index, MFT_CKC, 0); | ||
195 | + mft_writeb(qts, index, MFT_ICLR, MFT_ICLR_ALL); | ||
196 | + mft_writeb(qts, index, MFT_MCTRL, MFT_MCTRL_ALL); | ||
197 | + mft_writeb(qts, index, MFT_IEN, MFT_IEN_ALL); | ||
198 | + mft_writeb(qts, index, MFT_INASEL, 0); | ||
199 | + mft_writeb(qts, index, MFT_INBSEL, 0); | ||
200 | + | ||
201 | + /* Set cpcfg to use EQ mode, same as kernel driver */ | ||
202 | + mft_writeb(qts, index, MFT_CPCFG, MFT_CPCFG_EQ_MODE); | ||
203 | + | ||
204 | + /* Write default counters, timeout and prescaler */ | ||
205 | + mft_reset_counters(qts, index); | ||
206 | + mft_writeb(qts, index, MFT_PRSC, DEFAULT_PRSC); | ||
207 | + | ||
208 | + /* Write default max rpm via QMP */ | ||
209 | + mft_qom_set(qts, index, "max_rpm[0]", DEFAULT_RPM); | ||
210 | + mft_qom_set(qts, index, "max_rpm[1]", DEFAULT_RPM); | ||
211 | +} | ||
212 | + | ||
213 | +static int32_t mft_compute_cnt(uint32_t rpm, uint64_t clk) | ||
214 | +{ | ||
215 | + uint64_t cnt; | ||
216 | + | ||
217 | + if (rpm == 0) { | ||
218 | + return -1; | ||
219 | + } | ||
220 | + | ||
221 | + cnt = clk * 60 / ((DEFAULT_PRSC + 1) * rpm * MFT_PULSE_PER_REVOLUTION); | ||
222 | + if (cnt >= MFT_TIMEOUT) { | ||
223 | + return -1; | ||
224 | + } | ||
225 | + return MFT_MAX_CNT - cnt; | ||
226 | +} | ||
227 | + | ||
228 | +static void mft_verify_rpm(QTestState *qts, const TestData *td, uint64_t duty) | ||
229 | +{ | ||
230 | + int index = mft_compute_index(td); | ||
231 | + uint16_t cnt, cr; | ||
232 | + uint32_t rpm = DEFAULT_RPM * duty / MAX_DUTY; | ||
233 | + uint64_t clk = read_pclk(qts, true); | ||
234 | + int32_t expected_cnt = mft_compute_cnt(rpm, clk); | ||
235 | + | ||
236 | + qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); | ||
237 | + g_test_message( | ||
238 | + "verifying rpm for mft[%d]: clk: %lu, duty: %lu, rpm: %u, cnt: %d", | ||
239 | + index, clk, duty, rpm, expected_cnt); | ||
240 | + | ||
241 | + /* Verify rpm for fan A */ | ||
242 | + /* Stop capture */ | ||
243 | + mft_writeb(qts, index, MFT_CKC, 0); | ||
244 | + mft_writeb(qts, index, MFT_ICLR, MFT_ICLR_ALL); | ||
245 | + mft_reset_counters(qts, index); | ||
246 | + g_assert_cmphex(mft_readw(qts, index, MFT_CNT1), ==, MFT_MAX_CNT); | ||
247 | + g_assert_cmphex(mft_readw(qts, index, MFT_CRA), ==, MFT_MAX_CNT); | ||
248 | + g_assert_cmphex(mft_readw(qts, index, MFT_CPA), ==, | ||
249 | + MFT_MAX_CNT - MFT_TIMEOUT); | ||
250 | + /* Start capture */ | ||
251 | + mft_writeb(qts, index, MFT_CKC, MFT_CKC_C1CSEL); | ||
252 | + g_assert_true(qtest_get_irq(qts, MFT_IRQ(index))); | ||
253 | + if (expected_cnt == -1) { | ||
254 | + g_assert_cmphex(mft_readb(qts, index, MFT_ICTRL), ==, MFT_ICTRL_TEPND); | ||
255 | + } else { | ||
256 | + g_assert_cmphex(mft_readb(qts, index, MFT_ICTRL), ==, MFT_ICTRL_TAPND); | ||
257 | + cnt = mft_readw(qts, index, MFT_CNT1); | ||
258 | + /* | ||
259 | + * Due to error in clock measurement and rounding, we might have a small | ||
260 | + * error in measuring RPM. | ||
261 | + */ | ||
262 | + g_assert_cmphex(cnt + MAX_ERROR, >=, expected_cnt); | ||
263 | + g_assert_cmphex(cnt, <=, expected_cnt + MAX_ERROR); | ||
264 | + cr = mft_readw(qts, index, MFT_CRA); | ||
265 | + g_assert_cmphex(cnt, ==, cr); | ||
266 | + } | ||
267 | + | ||
268 | + /* Verify rpm for fan B */ | ||
269 | + | ||
270 | + qtest_irq_intercept_out(qts, "/machine/soc/a9mpcore/gic"); | ||
271 | +} | ||
272 | + | ||
273 | /* Check pwm registers can be reset to default value */ | ||
274 | static void test_init(gconstpointer test_data) | ||
275 | { | ||
276 | const TestData *td = test_data; | ||
277 | - QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
278 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
279 | int module = pwm_module_index(td->module); | ||
280 | int pwm = pwm_index(td->pwm); | ||
281 | |||
282 | @@ -XXX,XX +XXX,XX @@ static void test_init(gconstpointer test_data) | ||
283 | static void test_oneshot(gconstpointer test_data) | ||
284 | { | ||
285 | const TestData *td = test_data; | ||
286 | - QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
287 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
288 | int module = pwm_module_index(td->module); | ||
289 | int pwm = pwm_index(td->pwm); | ||
290 | uint32_t ppr, csr, pcr; | ||
291 | @@ -XXX,XX +XXX,XX @@ static void test_oneshot(gconstpointer test_data) | ||
292 | static void test_toggle(gconstpointer test_data) | ||
293 | { | ||
294 | const TestData *td = test_data; | ||
295 | - QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
296 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
297 | int module = pwm_module_index(td->module); | ||
298 | int pwm = pwm_index(td->pwm); | ||
299 | uint32_t ppr, csr, pcr, cnr, cmr; | ||
300 | int i, j, k, l; | ||
301 | uint64_t expected_freq, expected_duty; | ||
302 | |||
303 | + mft_init(qts, td); | ||
304 | + | ||
305 | pcr = CH_EN | CH_MOD; | ||
306 | for (i = 0; i < ARRAY_SIZE(ppr_list); ++i) { | ||
307 | ppr = ppr_list[i]; | ||
308 | @@ -XXX,XX +XXX,XX @@ static void test_toggle(gconstpointer test_data) | ||
309 | ==, expected_freq); | ||
310 | } | ||
311 | |||
312 | + /* Test MFT's RPM is correct. */ | ||
313 | + mft_verify_rpm(qts, td, expected_duty); | ||
314 | + | ||
315 | /* Test inverted mode */ | ||
316 | expected_duty = pwm_compute_duty(cnr, cmr, true); | ||
317 | pwm_write_pcr(qts, td, pcr | CH_INV); | ||
318 | -- | 73 | -- |
319 | 2.20.1 | 74 | 2.25.1 |
320 | 75 | ||
321 | 76 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Update the download URL of the Armbian 20.08 Bionic image for | 3 | The check semihosting_enabled() wants to know if the guest is |
4 | test_arm_orangepi_bionic_20_08 of the orangepi-pc machine. | 4 | currently in user mode. Unlike the other cases the test was inverted |
5 | causing us to block semihosting calls in non-EL0 modes. | ||
5 | 6 | ||
6 | The archive.armbian.com URL contains more images and should keep stable | 7 | Cc: qemu-stable@nongnu.org |
7 | for a longer period of time than dl.armbian.com. | 8 | Fixes: 19b26317e9 (target/arm: Honour -semihosting-config userspace=on) |
8 | 9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | |
9 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
13 | Message-id: 20210310195820.21950-4-nieklinnenbank@gmail.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 12 | --- |
16 | tests/acceptance/boot_linux_console.py | 2 +- | 13 | target/arm/translate.c | 2 +- |
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
18 | 15 | ||
19 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 16 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/tests/acceptance/boot_linux_console.py | 18 | --- a/target/arm/translate.c |
22 | +++ b/tests/acceptance/boot_linux_console.py | 19 | +++ b/target/arm/translate.c |
23 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_bionic_20_08(self): | 20 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) |
24 | # to 1036 MiB, but the underlying filesystem is 1552 MiB... | 21 | * semihosting, to provide some semblance of security |
25 | # As we expand it to 2 GiB we are safe. | 22 | * (and for consistency with our 32-bit semihosting). |
26 | 23 | */ | |
27 | - image_url = ('https://dl.armbian.com/orangepipc/archive/' | 24 | - if (semihosting_enabled(s->current_el != 0) && |
28 | + image_url = ('https://archive.armbian.com/orangepipc/archive/' | 25 | + if (semihosting_enabled(s->current_el == 0) && |
29 | 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') | 26 | (imm == (s->thumb ? 0x3c : 0xf000))) { |
30 | image_hash = ('b4d6775f5673486329e45a0586bf06b6' | 27 | gen_exception_internal_insn(s, EXCP_SEMIHOST); |
31 | 'dbe792199fd182ac6b9c7bb6c7d3e6dd') | 28 | return; |
32 | -- | 29 | -- |
33 | 2.20.1 | 30 | 2.25.1 |
34 | 31 | ||
35 | 32 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds GPIOs in NPCM7xx PWM module for its duty values. | 3 | Fix typos, add background information |
4 | The purpose of this is to connect it to the MFT module to provide | ||
5 | an input for measuring a PWM fan's RPM. Each PWM module has | ||
6 | NPCM7XX_PWM_PER_MODULE of GPIOs, each one corresponds to | ||
7 | one PWM instance and can connect to multiple fan instances in MFT. | ||
8 | 4 | ||
9 | Reviewed-by: Doug Evans <dje@google.com> | 5 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
10 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
11 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Message-id: 20210311180855.149764-2-wuhaotsh@google.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 8 | --- |
16 | include/hw/misc/npcm7xx_pwm.h | 4 +++- | 9 | hw/timer/imx_epit.c | 20 ++++++++++++++++---- |
17 | hw/misc/npcm7xx_pwm.c | 4 ++++ | 10 | 1 file changed, 16 insertions(+), 4 deletions(-) |
18 | 2 files changed, 7 insertions(+), 1 deletion(-) | ||
19 | 11 | ||
20 | diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h | 12 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
21 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/misc/npcm7xx_pwm.h | 14 | --- a/hw/timer/imx_epit.c |
23 | +++ b/include/hw/misc/npcm7xx_pwm.h | 15 | +++ b/hw/timer/imx_epit.c |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxPWM { | 16 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s) |
25 | * @iomem: Memory region through which registers are accessed. | ||
26 | * @clock: The PWM clock. | ||
27 | * @pwm: The PWM channels owned by this module. | ||
28 | + * @duty_gpio_out: The duty cycle of each PWM channels as a output GPIO. | ||
29 | * @ppr: The prescaler register. | ||
30 | * @csr: The clock selector register. | ||
31 | * @pcr: The control register. | ||
32 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState { | ||
33 | MemoryRegion iomem; | ||
34 | |||
35 | Clock *clock; | ||
36 | - NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE]; | ||
37 | + NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE]; | ||
38 | + qemu_irq duty_gpio_out[NPCM7XX_PWM_PER_MODULE]; | ||
39 | |||
40 | uint32_t ppr; | ||
41 | uint32_t csr; | ||
42 | diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/misc/npcm7xx_pwm.c | ||
45 | +++ b/hw/misc/npcm7xx_pwm.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_update_duty(NPCM7xxPWM *p) | ||
47 | trace_npcm7xx_pwm_update_duty(DEVICE(p->module)->canonical_path, | ||
48 | p->index, p->duty, duty); | ||
49 | p->duty = duty; | ||
50 | + qemu_set_irq(p->module->duty_gpio_out[p->index], p->duty); | ||
51 | } | 17 | } |
52 | } | 18 | } |
53 | 19 | ||
54 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_init(Object *obj) | 20 | +/* |
55 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 21 | + * This is called both on hardware (device) reset and software reset. |
56 | int i; | 22 | + */ |
57 | 23 | static void imx_epit_reset(DeviceState *dev) | |
58 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->pwm) != NPCM7XX_PWM_PER_MODULE); | 24 | { |
59 | for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) { | 25 | IMXEPITState *s = IMX_EPIT(dev); |
60 | NPCM7xxPWM *p = &s->pwm[i]; | 26 | |
61 | p->module = s; | 27 | - /* |
62 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_init(Object *obj) | 28 | - * Soft reset doesn't touch some bits; hard reset clears them |
63 | object_property_add_uint32_ptr(obj, "duty[*]", | 29 | - */ |
64 | &s->pwm[i].duty, OBJ_PROP_FLAG_READ); | 30 | + /* Soft reset doesn't touch some bits; hard reset clears them */ |
65 | } | 31 | s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); |
66 | + qdev_init_gpio_out_named(DEVICE(s), s->duty_gpio_out, | 32 | s->sr = 0; |
67 | + "duty-gpio-out", NPCM7XX_PWM_PER_MODULE); | 33 | s->lr = EPIT_TIMER_MAX; |
34 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||
35 | ptimer_transaction_begin(s->timer_cmp); | ||
36 | ptimer_transaction_begin(s->timer_reload); | ||
37 | |||
38 | + /* Update the frequency. Has been done already in case of a reset. */ | ||
39 | if (!(s->cr & CR_SWR)) { | ||
40 | imx_epit_set_freq(s); | ||
41 | } | ||
42 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||
43 | break; | ||
44 | |||
45 | case 1: /* SR - ACK*/ | ||
46 | - /* writing 1 to OCIF clear the OCIF bit */ | ||
47 | + /* writing 1 to OCIF clears the OCIF bit */ | ||
48 | if (value & 0x01) { | ||
49 | s->sr = 0; | ||
50 | imx_epit_update_int(s); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_realize(DeviceState *dev, Error **errp) | ||
52 | 0x00001000); | ||
53 | sysbus_init_mmio(sbd, &s->iomem); | ||
54 | |||
55 | + /* | ||
56 | + * The reload timer keeps running when the peripheral is enabled. It is a | ||
57 | + * kind of wall clock that does not generate any interrupts. The callback | ||
58 | + * needs to be provided, but it does nothing as the ptimer already supports | ||
59 | + * all necessary reloading functionality. | ||
60 | + */ | ||
61 | s->timer_reload = ptimer_init(imx_epit_reload, s, PTIMER_POLICY_LEGACY); | ||
62 | |||
63 | + /* | ||
64 | + * The compare timer is running only when the peripheral configuration is | ||
65 | + * in a state that will generate compare interrupts. | ||
66 | + */ | ||
67 | s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_LEGACY); | ||
68 | } | 68 | } |
69 | 69 | ||
70 | static const VMStateDescription vmstate_npcm7xx_pwm = { | ||
71 | -- | 70 | -- |
72 | 2.20.1 | 71 | 2.25.1 |
73 | |||
74 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | With the reduction operations, we intentionally increase maxsz to | 3 | remove unused defines, add needed defines |
4 | the next power of 2, so as to fill out the reduction tree correctly. | ||
5 | Since e2e7168a214b, oprsz must equal maxsz, with exceptions for small | ||
6 | vectors, so this triggers an assertion for vector sizes > 32 that are | ||
7 | not themselves a power of 2. | ||
8 | 4 | ||
9 | Pass the power-of-two value in the simd_data field instead. | 5 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20210309155305.11301-9-richard.henderson@linaro.org | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 8 | --- |
16 | target/arm/sve_helper.c | 2 +- | 9 | include/hw/timer/imx_epit.h | 4 ++-- |
17 | target/arm/translate-sve.c | 2 +- | 10 | hw/timer/imx_epit.c | 4 ++-- |
18 | 2 files changed, 2 insertions(+), 2 deletions(-) | 11 | 2 files changed, 4 insertions(+), 4 deletions(-) |
19 | 12 | ||
20 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 13 | diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/sve_helper.c | 15 | --- a/include/hw/timer/imx_epit.h |
23 | +++ b/target/arm/sve_helper.c | 16 | +++ b/include/hw/timer/imx_epit.h |
24 | @@ -XXX,XX +XXX,XX @@ static TYPE NAME##_reduce(TYPE *data, float_status *status, uintptr_t n) \ | 17 | @@ -XXX,XX +XXX,XX @@ |
25 | } \ | 18 | #define CR_OCIEN (1 << 2) |
26 | uint64_t HELPER(NAME)(void *vn, void *vg, void *vs, uint32_t desc) \ | 19 | #define CR_RLD (1 << 3) |
27 | { \ | 20 | #define CR_PRESCALE_SHIFT (4) |
28 | - uintptr_t i, oprsz = simd_oprsz(desc), maxsz = simd_maxsz(desc); \ | 21 | -#define CR_PRESCALE_MASK (0xfff) |
29 | + uintptr_t i, oprsz = simd_oprsz(desc), maxsz = simd_data(desc); \ | 22 | +#define CR_PRESCALE_BITS (12) |
30 | TYPE data[sizeof(ARMVectorReg) / sizeof(TYPE)]; \ | 23 | #define CR_SWR (1 << 16) |
31 | for (i = 0; i < oprsz; ) { \ | 24 | #define CR_IOVW (1 << 17) |
32 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \ | 25 | #define CR_DBGEN (1 << 18) |
33 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 26 | @@ -XXX,XX +XXX,XX @@ |
27 | #define CR_DOZEN (1 << 20) | ||
28 | #define CR_STOPEN (1 << 21) | ||
29 | #define CR_CLKSRC_SHIFT (24) | ||
30 | -#define CR_CLKSRC_MASK (0x3 << CR_CLKSRC_SHIFT) | ||
31 | +#define CR_CLKSRC_BITS (2) | ||
32 | |||
33 | #define EPIT_TIMER_MAX 0XFFFFFFFFUL | ||
34 | |||
35 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/translate-sve.c | 37 | --- a/hw/timer/imx_epit.c |
36 | +++ b/target/arm/translate-sve.c | 38 | +++ b/hw/timer/imx_epit.c |
37 | @@ -XXX,XX +XXX,XX @@ static void do_reduce(DisasContext *s, arg_rpr_esz *a, | 39 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s) |
38 | { | 40 | uint32_t clksrc; |
39 | unsigned vsz = vec_full_reg_size(s); | 41 | uint32_t prescaler; |
40 | unsigned p2vsz = pow2ceil(vsz); | 42 | |
41 | - TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, p2vsz, 0)); | 43 | - clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, 2); |
42 | + TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, vsz, p2vsz)); | 44 | - prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, 12); |
43 | TCGv_ptr t_zn, t_pg, status; | 45 | + clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS); |
44 | TCGv_i64 temp; | 46 | + prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS); |
45 | 47 | ||
48 | s->freq = imx_ccm_get_clock_frequency(s->ccm, | ||
49 | imx_epit_clocks[clksrc]) / prescaler; | ||
46 | -- | 50 | -- |
47 | 2.20.1 | 51 | 2.25.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Since b64ee454a4a0, all predicate operations should be | ||
4 | using these field macros for predicates. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210309155305.11301-6-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 5 | --- |
11 | target/arm/sve_helper.c | 30 ++++++++++++++---------------- | 6 | include/hw/timer/imx_epit.h | 2 ++ |
12 | target/arm/translate-sve.c | 4 ++-- | 7 | hw/timer/imx_epit.c | 12 ++++++------ |
13 | 2 files changed, 16 insertions(+), 18 deletions(-) | 8 | 2 files changed, 8 insertions(+), 6 deletions(-) |
14 | 9 | ||
15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 10 | diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h |
16 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/sve_helper.c | 12 | --- a/include/hw/timer/imx_epit.h |
18 | +++ b/target/arm/sve_helper.c | 13 | +++ b/include/hw/timer/imx_epit.h |
19 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_zero(ARMPredicateReg *d, intptr_t oprsz) | 14 | @@ -XXX,XX +XXX,XX @@ |
20 | void HELPER(sve_brkpa)(void *vd, void *vn, void *vm, void *vg, | 15 | #define CR_CLKSRC_SHIFT (24) |
21 | uint32_t pred_desc) | 16 | #define CR_CLKSRC_BITS (2) |
17 | |||
18 | +#define SR_OCIF (1 << 0) | ||
19 | + | ||
20 | #define EPIT_TIMER_MAX 0XFFFFFFFFUL | ||
21 | |||
22 | #define TYPE_IMX_EPIT "imx.epit" | ||
23 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/timer/imx_epit.c | ||
26 | +++ b/hw/timer/imx_epit.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static const IMXClk imx_epit_clocks[] = { | ||
28 | */ | ||
29 | static void imx_epit_update_int(IMXEPITState *s) | ||
22 | { | 30 | { |
23 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 31 | - if (s->sr && (s->cr & CR_OCIEN) && (s->cr & CR_EN)) { |
24 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | 32 | + if ((s->sr & SR_OCIF) && (s->cr & CR_OCIEN) && (s->cr & CR_EN)) { |
25 | if (last_active_pred(vn, vg, oprsz)) { | 33 | qemu_irq_raise(s->irq); |
26 | compute_brk_z(vd, vm, vg, oprsz, true); | ||
27 | } else { | 34 | } else { |
28 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_brkpa)(void *vd, void *vn, void *vm, void *vg, | 35 | qemu_irq_lower(s->irq); |
29 | uint32_t HELPER(sve_brkpas)(void *vd, void *vn, void *vm, void *vg, | 36 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, |
30 | uint32_t pred_desc) | 37 | break; |
31 | { | 38 | |
32 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 39 | case 1: /* SR - ACK*/ |
33 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | 40 | - /* writing 1 to OCIF clears the OCIF bit */ |
34 | if (last_active_pred(vn, vg, oprsz)) { | 41 | - if (value & 0x01) { |
35 | return compute_brks_z(vd, vm, vg, oprsz, true); | 42 | - s->sr = 0; |
36 | } else { | 43 | + /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */ |
37 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkpas)(void *vd, void *vn, void *vm, void *vg, | 44 | + if (value & SR_OCIF) { |
38 | void HELPER(sve_brkpb)(void *vd, void *vn, void *vm, void *vg, | 45 | + s->sr = 0; /* SR.OCIF is the only bit in this register anyway */ |
39 | uint32_t pred_desc) | 46 | imx_epit_update_int(s); |
40 | { | 47 | } |
41 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 48 | break; |
42 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | 49 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_cmp(void *opaque) |
43 | if (last_active_pred(vn, vg, oprsz)) { | 50 | IMXEPITState *s = IMX_EPIT(opaque); |
44 | compute_brk_z(vd, vm, vg, oprsz, false); | 51 | |
45 | } else { | 52 | DPRINTF("sr was %d\n", s->sr); |
46 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_brkpb)(void *vd, void *vn, void *vm, void *vg, | 53 | - |
47 | uint32_t HELPER(sve_brkpbs)(void *vd, void *vn, void *vm, void *vg, | 54 | - s->sr = 1; |
48 | uint32_t pred_desc) | 55 | + /* Set interrupt status bit SR.OCIF and update the interrupt state */ |
49 | { | 56 | + s->sr |= SR_OCIF; |
50 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 57 | imx_epit_update_int(s); |
51 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
52 | if (last_active_pred(vn, vg, oprsz)) { | ||
53 | return compute_brks_z(vd, vm, vg, oprsz, false); | ||
54 | } else { | ||
55 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkpbs)(void *vd, void *vn, void *vm, void *vg, | ||
56 | |||
57 | void HELPER(sve_brka_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
58 | { | ||
59 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
60 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
61 | compute_brk_z(vd, vn, vg, oprsz, true); | ||
62 | } | 58 | } |
63 | 59 | ||
64 | uint32_t HELPER(sve_brkas_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
65 | { | ||
66 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
67 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
68 | return compute_brks_z(vd, vn, vg, oprsz, true); | ||
69 | } | ||
70 | |||
71 | void HELPER(sve_brkb_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
72 | { | ||
73 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
74 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
75 | compute_brk_z(vd, vn, vg, oprsz, false); | ||
76 | } | ||
77 | |||
78 | uint32_t HELPER(sve_brkbs_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
79 | { | ||
80 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
81 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
82 | return compute_brks_z(vd, vn, vg, oprsz, false); | ||
83 | } | ||
84 | |||
85 | void HELPER(sve_brka_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
86 | { | ||
87 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
88 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
89 | compute_brk_m(vd, vn, vg, oprsz, true); | ||
90 | } | ||
91 | |||
92 | uint32_t HELPER(sve_brkas_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
93 | { | ||
94 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
95 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
96 | return compute_brks_m(vd, vn, vg, oprsz, true); | ||
97 | } | ||
98 | |||
99 | void HELPER(sve_brkb_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
100 | { | ||
101 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
102 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
103 | compute_brk_m(vd, vn, vg, oprsz, false); | ||
104 | } | ||
105 | |||
106 | uint32_t HELPER(sve_brkbs_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
107 | { | ||
108 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
109 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
110 | return compute_brks_m(vd, vn, vg, oprsz, false); | ||
111 | } | ||
112 | |||
113 | void HELPER(sve_brkn)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
114 | { | ||
115 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
116 | - | ||
117 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
118 | if (!last_active_pred(vn, vg, oprsz)) { | ||
119 | do_zero(vd, oprsz); | ||
120 | } | ||
121 | @@ -XXX,XX +XXX,XX @@ static uint32_t predtest_ones(ARMPredicateReg *d, intptr_t oprsz, | ||
122 | |||
123 | uint32_t HELPER(sve_brkns)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
124 | { | ||
125 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
126 | - | ||
127 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
128 | if (last_active_pred(vn, vg, oprsz)) { | ||
129 | return predtest_ones(vd, oprsz, -1); | ||
130 | } else { | ||
131 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate-sve.c | ||
134 | +++ b/target/arm/translate-sve.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static bool do_brk3(DisasContext *s, arg_rprr_s *a, | ||
136 | TCGv_ptr n = tcg_temp_new_ptr(); | ||
137 | TCGv_ptr m = tcg_temp_new_ptr(); | ||
138 | TCGv_ptr g = tcg_temp_new_ptr(); | ||
139 | - TCGv_i32 t = tcg_const_i32(vsz - 2); | ||
140 | + TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz)); | ||
141 | |||
142 | tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd)); | ||
143 | tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn)); | ||
144 | @@ -XXX,XX +XXX,XX @@ static bool do_brk2(DisasContext *s, arg_rpr_s *a, | ||
145 | TCGv_ptr d = tcg_temp_new_ptr(); | ||
146 | TCGv_ptr n = tcg_temp_new_ptr(); | ||
147 | TCGv_ptr g = tcg_temp_new_ptr(); | ||
148 | - TCGv_i32 t = tcg_const_i32(vsz - 2); | ||
149 | + TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz)); | ||
150 | |||
151 | tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd)); | ||
152 | tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn)); | ||
153 | -- | 60 | -- |
154 | 2.20.1 | 61 | 2.25.1 |
155 | |||
156 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Missed out on compressing the second half of a predicate | 3 | The interrupt state can change due to: |
4 | with length vl % 512 > 256. | 4 | - reset clears both SR.OCIF and CR.OCIE |
5 | - write to CR.EN or CR.OCIE | ||
5 | 6 | ||
6 | Adjust all of the x + (y << s) to x | (y << s) as a | 7 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
7 | general style fix. Drop the extract64 because the input | ||
8 | uint64_t are known to be already zero-extended from the | ||
9 | current size of the predicate. | ||
10 | |||
11 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210309155305.11301-2-richard.henderson@linaro.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | target/arm/sve_helper.c | 30 +++++++++++++++++++++--------- | 11 | hw/timer/imx_epit.c | 16 ++++++++++++---- |
18 | 1 file changed, 21 insertions(+), 9 deletions(-) | 12 | 1 file changed, 12 insertions(+), 4 deletions(-) |
19 | 13 | ||
20 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 14 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/sve_helper.c | 16 | --- a/hw/timer/imx_epit.c |
23 | +++ b/target/arm/sve_helper.c | 17 | +++ b/hw/timer/imx_epit.c |
24 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | 18 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, |
25 | if (oprsz <= 8) { | 19 | if (s->cr & CR_SWR) { |
26 | l = compress_bits(n[0] >> odd, esz); | 20 | /* handle the reset */ |
27 | h = compress_bits(m[0] >> odd, esz); | 21 | imx_epit_reset(DEVICE(s)); |
28 | - d[0] = extract64(l + (h << (4 * oprsz)), 0, 8 * oprsz); | 22 | - /* |
29 | + d[0] = l | (h << (4 * oprsz)); | 23 | - * TODO: could we 'break' here? following operations appear |
30 | } else { | 24 | - * to duplicate the work imx_epit_reset() already did. |
31 | ARMPredicateReg tmp_m; | 25 | - */ |
32 | intptr_t oprsz_16 = oprsz / 16; | ||
33 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | ||
34 | h = n[2 * i + 1]; | ||
35 | l = compress_bits(l >> odd, esz); | ||
36 | h = compress_bits(h >> odd, esz); | ||
37 | - d[i] = l + (h << 32); | ||
38 | + d[i] = l | (h << 32); | ||
39 | } | 26 | } |
40 | 27 | ||
41 | - /* For VL which is not a power of 2, the results from M do not | ||
42 | - align nicely with the uint64_t for D. Put the aligned results | ||
43 | - from M into TMP_M and then copy it into place afterward. */ | ||
44 | + /* | 28 | + /* |
45 | + * For VL which is not a multiple of 512, the results from M do not | 29 | + * The interrupt state can change due to: |
46 | + * align nicely with the uint64_t for D. Put the aligned results | 30 | + * - reset clears both SR.OCIF and CR.OCIE |
47 | + * from M into TMP_M and then copy it into place afterward. | 31 | + * - write to CR.EN or CR.OCIE |
48 | + */ | 32 | + */ |
49 | if (oprsz & 15) { | 33 | + imx_epit_update_int(s); |
50 | - d[i] = compress_bits(n[2 * i] >> odd, esz); | ||
51 | + int final_shift = (oprsz & 15) * 2; | ||
52 | + | 34 | + |
53 | + l = n[2 * i + 0]; | 35 | + /* |
54 | + h = n[2 * i + 1]; | 36 | + * TODO: could we 'break' here for reset? following operations appear |
55 | + l = compress_bits(l >> odd, esz); | 37 | + * to duplicate the work imx_epit_reset() already did. |
56 | + h = compress_bits(h >> odd, esz); | 38 | + */ |
57 | + d[i] = l | (h << final_shift); | 39 | + |
58 | 40 | ptimer_transaction_begin(s->timer_cmp); | |
59 | for (i = 0; i < oprsz_16; i++) { | 41 | ptimer_transaction_begin(s->timer_reload); |
60 | l = m[2 * i + 0]; | 42 | |
61 | h = m[2 * i + 1]; | ||
62 | l = compress_bits(l >> odd, esz); | ||
63 | h = compress_bits(h >> odd, esz); | ||
64 | - tmp_m.p[i] = l + (h << 32); | ||
65 | + tmp_m.p[i] = l | (h << 32); | ||
66 | } | ||
67 | - tmp_m.p[i] = compress_bits(m[2 * i] >> odd, esz); | ||
68 | + l = m[2 * i + 0]; | ||
69 | + h = m[2 * i + 1]; | ||
70 | + l = compress_bits(l >> odd, esz); | ||
71 | + h = compress_bits(h >> odd, esz); | ||
72 | + tmp_m.p[i] = l | (h << final_shift); | ||
73 | |||
74 | swap_memmove(vd + oprsz / 2, &tmp_m, oprsz / 2); | ||
75 | } else { | ||
76 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | ||
77 | h = m[2 * i + 1]; | ||
78 | l = compress_bits(l >> odd, esz); | ||
79 | h = compress_bits(h >> odd, esz); | ||
80 | - d[oprsz_16 + i] = l + (h << 32); | ||
81 | + d[oprsz_16 + i] = l | (h << 32); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | -- | 43 | -- |
86 | 2.20.1 | 44 | 2.25.1 |
87 | |||
88 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Since b64ee454a4a0, all predicate operations should be | 3 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
4 | using these field macros for predicates. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210309155305.11301-5-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 6 | --- |
11 | target/arm/sve_helper.c | 6 +++--- | 7 | hw/timer/imx_epit.c | 20 ++++++++++++++------ |
12 | target/arm/translate-sve.c | 7 +++---- | 8 | 1 file changed, 14 insertions(+), 6 deletions(-) |
13 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
14 | 9 | ||
15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 10 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
16 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/sve_helper.c | 12 | --- a/hw/timer/imx_epit.c |
18 | +++ b/target/arm/sve_helper.c | 13 | +++ b/hw/timer/imx_epit.c |
19 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_compact_d)(void *vd, void *vn, void *vg, uint32_t desc) | 14 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s) |
15 | /* | ||
16 | * This is called both on hardware (device) reset and software reset. | ||
20 | */ | 17 | */ |
21 | int32_t HELPER(sve_last_active_element)(void *vg, uint32_t pred_desc) | 18 | -static void imx_epit_reset(DeviceState *dev) |
19 | +static void imx_epit_reset(IMXEPITState *s, bool is_hard_reset) | ||
22 | { | 20 | { |
23 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 21 | - IMXEPITState *s = IMX_EPIT(dev); |
24 | - intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2); | 22 | - |
25 | + intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8); | 23 | /* Soft reset doesn't touch some bits; hard reset clears them */ |
26 | + intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); | 24 | - s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); |
27 | 25 | + if (is_hard_reset) { | |
28 | - return last_active_element(vg, DIV_ROUND_UP(oprsz, 8), esz); | 26 | + s->cr = 0; |
29 | + return last_active_element(vg, words, esz); | 27 | + } else { |
28 | + s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); | ||
29 | + } | ||
30 | s->sr = 0; | ||
31 | s->lr = EPIT_TIMER_MAX; | ||
32 | s->cmp = 0; | ||
33 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||
34 | s->cr = value & 0x03ffffff; | ||
35 | if (s->cr & CR_SWR) { | ||
36 | /* handle the reset */ | ||
37 | - imx_epit_reset(DEVICE(s)); | ||
38 | + imx_epit_reset(s, false); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_realize(DeviceState *dev, Error **errp) | ||
43 | s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_LEGACY); | ||
30 | } | 44 | } |
31 | 45 | ||
32 | void HELPER(sve_splice)(void *vd, void *vn, void *vm, void *vg, uint32_t desc) | 46 | +static void imx_epit_dev_reset(DeviceState *dev) |
33 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 47 | +{ |
34 | index XXXXXXX..XXXXXXX 100644 | 48 | + IMXEPITState *s = IMX_EPIT(dev); |
35 | --- a/target/arm/translate-sve.c | 49 | + imx_epit_reset(s, true); |
36 | +++ b/target/arm/translate-sve.c | 50 | +} |
37 | @@ -XXX,XX +XXX,XX @@ static void find_last_active(DisasContext *s, TCGv_i32 ret, int esz, int pg) | 51 | + |
38 | */ | 52 | static void imx_epit_class_init(ObjectClass *klass, void *data) |
39 | TCGv_ptr t_p = tcg_temp_new_ptr(); | 53 | { |
40 | TCGv_i32 t_desc; | 54 | DeviceClass *dc = DEVICE_CLASS(klass); |
41 | - unsigned vsz = pred_full_reg_size(s); | 55 | |
42 | - unsigned desc; | 56 | dc->realize = imx_epit_realize; |
43 | + unsigned desc = 0; | 57 | - dc->reset = imx_epit_reset; |
44 | 58 | + dc->reset = imx_epit_dev_reset; | |
45 | - desc = vsz - 2; | 59 | dc->vmsd = &vmstate_imx_timer_epit; |
46 | - desc = deposit32(desc, SIMD_DATA_SHIFT, 2, esz); | 60 | dc->desc = "i.MX periodic timer"; |
47 | + desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s)); | 61 | } |
48 | + desc = FIELD_DP32(desc, PREDDESC, ESZ, esz); | ||
49 | |||
50 | tcg_gen_addi_ptr(t_p, cpu_env, pred_full_reg_offset(s, pg)); | ||
51 | t_desc = tcg_const_i32(desc); | ||
52 | -- | 62 | -- |
53 | 2.20.1 | 63 | 2.25.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | We're about to move code from the template header into pxa2xx_lcd.c. | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | Before doing that, make coding style fixes so checkpatch doesn't | ||
3 | complain about the patch which moves the code. This commit is | ||
4 | whitespace changes only: | ||
5 | * avoid hard-coded tabs | ||
6 | * fix ident on function prototypes | ||
7 | * no newline before open brace on array definitions | ||
8 | 2 | ||
3 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
11 | Message-id: 20210211141515.8755-9-peter.maydell@linaro.org | ||
12 | --- | 6 | --- |
13 | hw/display/pxa2xx_template.h | 66 +++++++++++++++++------------------- | 7 | hw/timer/imx_epit.c | 215 ++++++++++++++++++++++++-------------------- |
14 | 1 file changed, 32 insertions(+), 34 deletions(-) | 8 | 1 file changed, 117 insertions(+), 98 deletions(-) |
15 | 9 | ||
16 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h | 10 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
17 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/display/pxa2xx_template.h | 12 | --- a/hw/timer/imx_epit.c |
19 | +++ b/hw/display/pxa2xx_template.h | 13 | +++ b/hw/timer/imx_epit.c |
20 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s) |
21 | } while (0) | ||
22 | |||
23 | #ifdef HOST_WORDS_BIGENDIAN | ||
24 | -# define SWAP_WORDS 1 | ||
25 | +# define SWAP_WORDS 1 | ||
26 | #endif | ||
27 | |||
28 | -#define FN_2(x) FN(x + 1) FN(x) | ||
29 | -#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
30 | +#define FN_2(x) FN(x + 1) FN(x) | ||
31 | +#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
32 | |||
33 | -static void pxa2xx_draw_line2(void *opaque, | ||
34 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
35 | +static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src, | ||
36 | + int width, int deststep) | ||
37 | { | ||
38 | uint32_t *palette = opaque; | ||
39 | uint32_t data; | ||
40 | while (width > 0) { | ||
41 | data = *(uint32_t *) src; | ||
42 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
43 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
44 | #ifdef SWAP_WORDS | ||
45 | FN_4(12) | ||
46 | FN_4(8) | ||
47 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line2(void *opaque, | ||
48 | } | 15 | } |
49 | } | 16 | } |
50 | 17 | ||
51 | -static void pxa2xx_draw_line4(void *opaque, | 18 | +static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
52 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | 19 | +{ |
53 | +static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src, | 20 | + uint32_t oldcr = s->cr; |
54 | + int width, int deststep) | 21 | + |
22 | + s->cr = value & 0x03ffffff; | ||
23 | + | ||
24 | + if (s->cr & CR_SWR) { | ||
25 | + /* handle the reset */ | ||
26 | + imx_epit_reset(s, false); | ||
27 | + } | ||
28 | + | ||
29 | + /* | ||
30 | + * The interrupt state can change due to: | ||
31 | + * - reset clears both SR.OCIF and CR.OCIE | ||
32 | + * - write to CR.EN or CR.OCIE | ||
33 | + */ | ||
34 | + imx_epit_update_int(s); | ||
35 | + | ||
36 | + /* | ||
37 | + * TODO: could we 'break' here for reset? following operations appear | ||
38 | + * to duplicate the work imx_epit_reset() already did. | ||
39 | + */ | ||
40 | + | ||
41 | + ptimer_transaction_begin(s->timer_cmp); | ||
42 | + ptimer_transaction_begin(s->timer_reload); | ||
43 | + | ||
44 | + /* Update the frequency. Has been done already in case of a reset. */ | ||
45 | + if (!(s->cr & CR_SWR)) { | ||
46 | + imx_epit_set_freq(s); | ||
47 | + } | ||
48 | + | ||
49 | + if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { | ||
50 | + if (s->cr & CR_ENMOD) { | ||
51 | + if (s->cr & CR_RLD) { | ||
52 | + ptimer_set_limit(s->timer_reload, s->lr, 1); | ||
53 | + ptimer_set_limit(s->timer_cmp, s->lr, 1); | ||
54 | + } else { | ||
55 | + ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1); | ||
56 | + ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1); | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + imx_epit_reload_compare_timer(s); | ||
61 | + ptimer_run(s->timer_reload, 0); | ||
62 | + if (s->cr & CR_OCIEN) { | ||
63 | + ptimer_run(s->timer_cmp, 0); | ||
64 | + } else { | ||
65 | + ptimer_stop(s->timer_cmp); | ||
66 | + } | ||
67 | + } else if (!(s->cr & CR_EN)) { | ||
68 | + /* stop both timers */ | ||
69 | + ptimer_stop(s->timer_reload); | ||
70 | + ptimer_stop(s->timer_cmp); | ||
71 | + } else if (s->cr & CR_OCIEN) { | ||
72 | + if (!(oldcr & CR_OCIEN)) { | ||
73 | + imx_epit_reload_compare_timer(s); | ||
74 | + ptimer_run(s->timer_cmp, 0); | ||
75 | + } | ||
76 | + } else { | ||
77 | + ptimer_stop(s->timer_cmp); | ||
78 | + } | ||
79 | + | ||
80 | + ptimer_transaction_commit(s->timer_cmp); | ||
81 | + ptimer_transaction_commit(s->timer_reload); | ||
82 | +} | ||
83 | + | ||
84 | +static void imx_epit_write_sr(IMXEPITState *s, uint32_t value) | ||
85 | +{ | ||
86 | + /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */ | ||
87 | + if (value & SR_OCIF) { | ||
88 | + s->sr = 0; /* SR.OCIF is the only bit in this register anyway */ | ||
89 | + imx_epit_update_int(s); | ||
90 | + } | ||
91 | +} | ||
92 | + | ||
93 | +static void imx_epit_write_lr(IMXEPITState *s, uint32_t value) | ||
94 | +{ | ||
95 | + s->lr = value; | ||
96 | + | ||
97 | + ptimer_transaction_begin(s->timer_cmp); | ||
98 | + ptimer_transaction_begin(s->timer_reload); | ||
99 | + if (s->cr & CR_RLD) { | ||
100 | + /* Also set the limit if the LRD bit is set */ | ||
101 | + /* If IOVW bit is set then set the timer value */ | ||
102 | + ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW); | ||
103 | + ptimer_set_limit(s->timer_cmp, s->lr, 0); | ||
104 | + } else if (s->cr & CR_IOVW) { | ||
105 | + /* If IOVW bit is set then set the timer value */ | ||
106 | + ptimer_set_count(s->timer_reload, s->lr); | ||
107 | + } | ||
108 | + /* | ||
109 | + * Commit the change to s->timer_reload, so it can propagate. Otherwise | ||
110 | + * the timer interrupt may not fire properly. The commit must happen | ||
111 | + * before calling imx_epit_reload_compare_timer(), which reads | ||
112 | + * s->timer_reload internally again. | ||
113 | + */ | ||
114 | + ptimer_transaction_commit(s->timer_reload); | ||
115 | + imx_epit_reload_compare_timer(s); | ||
116 | + ptimer_transaction_commit(s->timer_cmp); | ||
117 | +} | ||
118 | + | ||
119 | +static void imx_epit_write_cmp(IMXEPITState *s, uint32_t value) | ||
120 | +{ | ||
121 | + s->cmp = value; | ||
122 | + | ||
123 | + ptimer_transaction_begin(s->timer_cmp); | ||
124 | + imx_epit_reload_compare_timer(s); | ||
125 | + ptimer_transaction_commit(s->timer_cmp); | ||
126 | +} | ||
127 | + | ||
128 | static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||
129 | unsigned size) | ||
55 | { | 130 | { |
56 | uint32_t *palette = opaque; | 131 | IMXEPITState *s = IMX_EPIT(opaque); |
57 | uint32_t data; | 132 | - uint64_t oldcr; |
58 | while (width > 0) { | 133 | |
59 | data = *(uint32_t *) src; | 134 | DPRINTF("(%s, value = 0x%08x)\n", imx_epit_reg_name(offset >> 2), |
60 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | 135 | (uint32_t)value); |
61 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | 136 | |
62 | #ifdef SWAP_WORDS | 137 | switch (offset >> 2) { |
63 | FN_2(6) | 138 | case 0: /* CR */ |
64 | FN_2(4) | 139 | - |
65 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line4(void *opaque, | 140 | - oldcr = s->cr; |
141 | - s->cr = value & 0x03ffffff; | ||
142 | - if (s->cr & CR_SWR) { | ||
143 | - /* handle the reset */ | ||
144 | - imx_epit_reset(s, false); | ||
145 | - } | ||
146 | - | ||
147 | - /* | ||
148 | - * The interrupt state can change due to: | ||
149 | - * - reset clears both SR.OCIF and CR.OCIE | ||
150 | - * - write to CR.EN or CR.OCIE | ||
151 | - */ | ||
152 | - imx_epit_update_int(s); | ||
153 | - | ||
154 | - /* | ||
155 | - * TODO: could we 'break' here for reset? following operations appear | ||
156 | - * to duplicate the work imx_epit_reset() already did. | ||
157 | - */ | ||
158 | - | ||
159 | - ptimer_transaction_begin(s->timer_cmp); | ||
160 | - ptimer_transaction_begin(s->timer_reload); | ||
161 | - | ||
162 | - /* Update the frequency. Has been done already in case of a reset. */ | ||
163 | - if (!(s->cr & CR_SWR)) { | ||
164 | - imx_epit_set_freq(s); | ||
165 | - } | ||
166 | - | ||
167 | - if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { | ||
168 | - if (s->cr & CR_ENMOD) { | ||
169 | - if (s->cr & CR_RLD) { | ||
170 | - ptimer_set_limit(s->timer_reload, s->lr, 1); | ||
171 | - ptimer_set_limit(s->timer_cmp, s->lr, 1); | ||
172 | - } else { | ||
173 | - ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1); | ||
174 | - ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1); | ||
175 | - } | ||
176 | - } | ||
177 | - | ||
178 | - imx_epit_reload_compare_timer(s); | ||
179 | - ptimer_run(s->timer_reload, 0); | ||
180 | - if (s->cr & CR_OCIEN) { | ||
181 | - ptimer_run(s->timer_cmp, 0); | ||
182 | - } else { | ||
183 | - ptimer_stop(s->timer_cmp); | ||
184 | - } | ||
185 | - } else if (!(s->cr & CR_EN)) { | ||
186 | - /* stop both timers */ | ||
187 | - ptimer_stop(s->timer_reload); | ||
188 | - ptimer_stop(s->timer_cmp); | ||
189 | - } else if (s->cr & CR_OCIEN) { | ||
190 | - if (!(oldcr & CR_OCIEN)) { | ||
191 | - imx_epit_reload_compare_timer(s); | ||
192 | - ptimer_run(s->timer_cmp, 0); | ||
193 | - } | ||
194 | - } else { | ||
195 | - ptimer_stop(s->timer_cmp); | ||
196 | - } | ||
197 | - | ||
198 | - ptimer_transaction_commit(s->timer_cmp); | ||
199 | - ptimer_transaction_commit(s->timer_reload); | ||
200 | + imx_epit_write_cr(s, (uint32_t)value); | ||
201 | break; | ||
202 | |||
203 | - case 1: /* SR - ACK*/ | ||
204 | - /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */ | ||
205 | - if (value & SR_OCIF) { | ||
206 | - s->sr = 0; /* SR.OCIF is the only bit in this register anyway */ | ||
207 | - imx_epit_update_int(s); | ||
208 | - } | ||
209 | + case 1: /* SR */ | ||
210 | + imx_epit_write_sr(s, (uint32_t)value); | ||
211 | break; | ||
212 | |||
213 | - case 2: /* LR - set ticks */ | ||
214 | - s->lr = value; | ||
215 | - | ||
216 | - ptimer_transaction_begin(s->timer_cmp); | ||
217 | - ptimer_transaction_begin(s->timer_reload); | ||
218 | - if (s->cr & CR_RLD) { | ||
219 | - /* Also set the limit if the LRD bit is set */ | ||
220 | - /* If IOVW bit is set then set the timer value */ | ||
221 | - ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW); | ||
222 | - ptimer_set_limit(s->timer_cmp, s->lr, 0); | ||
223 | - } else if (s->cr & CR_IOVW) { | ||
224 | - /* If IOVW bit is set then set the timer value */ | ||
225 | - ptimer_set_count(s->timer_reload, s->lr); | ||
226 | - } | ||
227 | - /* | ||
228 | - * Commit the change to s->timer_reload, so it can propagate. Otherwise | ||
229 | - * the timer interrupt may not fire properly. The commit must happen | ||
230 | - * before calling imx_epit_reload_compare_timer(), which reads | ||
231 | - * s->timer_reload internally again. | ||
232 | - */ | ||
233 | - ptimer_transaction_commit(s->timer_reload); | ||
234 | - imx_epit_reload_compare_timer(s); | ||
235 | - ptimer_transaction_commit(s->timer_cmp); | ||
236 | + case 2: /* LR */ | ||
237 | + imx_epit_write_lr(s, (uint32_t)value); | ||
238 | break; | ||
239 | |||
240 | case 3: /* CMP */ | ||
241 | - s->cmp = value; | ||
242 | - | ||
243 | - ptimer_transaction_begin(s->timer_cmp); | ||
244 | - imx_epit_reload_compare_timer(s); | ||
245 | - ptimer_transaction_commit(s->timer_cmp); | ||
246 | - | ||
247 | + imx_epit_write_cmp(s, (uint32_t)value); | ||
248 | break; | ||
249 | |||
250 | default: | ||
251 | qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
252 | HWADDR_PRIx "\n", TYPE_IMX_EPIT, __func__, offset); | ||
253 | - | ||
254 | break; | ||
66 | } | 255 | } |
67 | } | 256 | } |
68 | 257 | + | |
69 | -static void pxa2xx_draw_line8(void *opaque, | 258 | static void imx_epit_cmp(void *opaque) |
70 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
71 | +static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src, | ||
72 | + int width, int deststep) | ||
73 | { | 259 | { |
74 | uint32_t *palette = opaque; | 260 | IMXEPITState *s = IMX_EPIT(opaque); |
75 | uint32_t data; | ||
76 | while (width > 0) { | ||
77 | data = *(uint32_t *) src; | ||
78 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
79 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
80 | #ifdef SWAP_WORDS | ||
81 | FN(24) | ||
82 | FN(16) | ||
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line8(void *opaque, | ||
84 | } | ||
85 | } | ||
86 | |||
87 | -static void pxa2xx_draw_line16(void *opaque, | ||
88 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
89 | +static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src, | ||
90 | + int width, int deststep) | ||
91 | { | ||
92 | uint32_t data; | ||
93 | unsigned int r, g, b; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16(void *opaque, | ||
95 | } | ||
96 | } | ||
97 | |||
98 | -static void pxa2xx_draw_line16t(void *opaque, | ||
99 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
100 | +static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
101 | + int width, int deststep) | ||
102 | { | ||
103 | uint32_t data; | ||
104 | unsigned int r, g, b; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque, | ||
106 | } | ||
107 | } | ||
108 | |||
109 | -static void pxa2xx_draw_line18(void *opaque, | ||
110 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
111 | +static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src, | ||
112 | + int width, int deststep) | ||
113 | { | ||
114 | uint32_t data; | ||
115 | unsigned int r, g, b; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line18(void *opaque, | ||
117 | } | ||
118 | |||
119 | /* The wicked packed format */ | ||
120 | -static void pxa2xx_draw_line18p(void *opaque, | ||
121 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
122 | +static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
123 | + int width, int deststep) | ||
124 | { | ||
125 | uint32_t data[3]; | ||
126 | unsigned int r, g, b; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line18p(void *opaque, | ||
128 | } | ||
129 | } | ||
130 | |||
131 | -static void pxa2xx_draw_line19(void *opaque, | ||
132 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
133 | +static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src, | ||
134 | + int width, int deststep) | ||
135 | { | ||
136 | uint32_t data; | ||
137 | unsigned int r, g, b; | ||
138 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19(void *opaque, | ||
139 | } | ||
140 | |||
141 | /* The wicked packed format */ | ||
142 | -static void pxa2xx_draw_line19p(void *opaque, | ||
143 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
144 | +static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
145 | + int width, int deststep) | ||
146 | { | ||
147 | uint32_t data[3]; | ||
148 | unsigned int r, g, b; | ||
149 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, | ||
150 | } | ||
151 | } | ||
152 | |||
153 | -static void pxa2xx_draw_line24(void *opaque, | ||
154 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
155 | +static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src, | ||
156 | + int width, int deststep) | ||
157 | { | ||
158 | uint32_t data; | ||
159 | unsigned int r, g, b; | ||
160 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24(void *opaque, | ||
161 | } | ||
162 | } | ||
163 | |||
164 | -static void pxa2xx_draw_line24t(void *opaque, | ||
165 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
166 | +static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
167 | + int width, int deststep) | ||
168 | { | ||
169 | uint32_t data; | ||
170 | unsigned int r, g, b; | ||
171 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24t(void *opaque, | ||
172 | } | ||
173 | } | ||
174 | |||
175 | -static void pxa2xx_draw_line25(void *opaque, | ||
176 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
177 | +static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src, | ||
178 | + int width, int deststep) | ||
179 | { | ||
180 | uint32_t data; | ||
181 | unsigned int r, g, b; | ||
182 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line25(void *opaque, | ||
183 | } | ||
184 | |||
185 | /* Overlay planes disabled, no transparency */ | ||
186 | -static drawfn pxa2xx_draw_fn_32[16] = | ||
187 | -{ | ||
188 | +static drawfn pxa2xx_draw_fn_32[16] = { | ||
189 | [0 ... 0xf] = NULL, | ||
190 | [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
191 | [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
192 | @@ -XXX,XX +XXX,XX @@ static drawfn pxa2xx_draw_fn_32[16] = | ||
193 | }; | ||
194 | |||
195 | /* Overlay planes enabled, transparency used */ | ||
196 | -static drawfn pxa2xx_draw_fn_32t[16] = | ||
197 | -{ | ||
198 | +static drawfn pxa2xx_draw_fn_32t[16] = { | ||
199 | [0 ... 0xf] = NULL, | ||
200 | [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
201 | [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
202 | -- | 261 | -- |
203 | 2.20.1 | 262 | 2.25.1 |
204 | |||
205 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Currently get_naturally_aligned_size() is used by the intel iommu | 3 | The CNT register is a read-only register. There is no need to |
4 | to compute the maximum invalidation range based on @size which is | 4 | store it's value, it can be calculated on demand. |
5 | a power of 2 while being aligned with the @start address and less | 5 | The calculated frequency is needed temporarily only. |
6 | than the maximum range defined by @gaw. | ||
7 | 6 | ||
8 | This helper is also useful for other iommu devices (virtio-iommu, | 7 | Note that this is a migration compatibility break for all boards |
9 | SMMUv3) to make sure IOMMU UNMAP notifiers only are called with | 8 | types that use the EPIT peripheral. |
10 | power of 2 range sizes. | ||
11 | 9 | ||
12 | Let's move this latter into dma-helpers.c and rename it into | 10 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
13 | dma_aligned_pow2_mask(). Also rewrite the helper so that it | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | accomodates UINT64_MAX values for the size mask and max mask. | ||
15 | It now returns a mask instead of a size. Change the caller. | ||
16 | |||
17 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
19 | Message-id: 20210309102742.30442-3-eric.auger@redhat.com | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 13 | --- |
22 | include/sysemu/dma.h | 12 ++++++++++++ | 14 | include/hw/timer/imx_epit.h | 2 - |
23 | hw/i386/intel_iommu.c | 30 +++++++----------------------- | 15 | hw/timer/imx_epit.c | 73 ++++++++++++++----------------------- |
24 | softmmu/dma-helpers.c | 26 ++++++++++++++++++++++++++ | 16 | 2 files changed, 28 insertions(+), 47 deletions(-) |
25 | 3 files changed, 45 insertions(+), 23 deletions(-) | ||
26 | 17 | ||
27 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | 18 | diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h |
28 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/include/sysemu/dma.h | 20 | --- a/include/hw/timer/imx_epit.h |
30 | +++ b/include/sysemu/dma.h | 21 | +++ b/include/hw/timer/imx_epit.h |
31 | @@ -XXX,XX +XXX,XX @@ uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); | 22 | @@ -XXX,XX +XXX,XX @@ struct IMXEPITState { |
32 | void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, | 23 | uint32_t sr; |
33 | QEMUSGList *sg, enum BlockAcctType type); | 24 | uint32_t lr; |
34 | 25 | uint32_t cmp; | |
35 | +/** | 26 | - uint32_t cnt; |
36 | + * dma_aligned_pow2_mask: Return the address bit mask of the largest | 27 | |
37 | + * power of 2 size less or equal than @end - @start + 1, aligned with @start, | 28 | - uint32_t freq; |
38 | + * and bounded by 1 << @max_addr_bits bits. | 29 | qemu_irq irq; |
39 | + * | 30 | }; |
40 | + * @start: range start address | 31 | |
41 | + * @end: range end address (greater than @start) | 32 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
42 | + * @max_addr_bits: max address bits (<= 64) | 33 | index XXXXXXX..XXXXXXX 100644 |
43 | + */ | 34 | --- a/hw/timer/imx_epit.c |
44 | +uint64_t dma_aligned_pow2_mask(uint64_t start, uint64_t end, | 35 | +++ b/hw/timer/imx_epit.c |
45 | + int max_addr_bits); | 36 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_update_int(IMXEPITState *s) |
37 | } | ||
38 | } | ||
39 | |||
40 | -/* | ||
41 | - * Must be called from within a ptimer_transaction_begin/commit block | ||
42 | - * for both s->timer_cmp and s->timer_reload. | ||
43 | - */ | ||
44 | -static void imx_epit_set_freq(IMXEPITState *s) | ||
45 | +static uint32_t imx_epit_get_freq(IMXEPITState *s) | ||
46 | { | ||
47 | - uint32_t clksrc; | ||
48 | - uint32_t prescaler; | ||
49 | - | ||
50 | - clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS); | ||
51 | - prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS); | ||
52 | - | ||
53 | - s->freq = imx_ccm_get_clock_frequency(s->ccm, | ||
54 | - imx_epit_clocks[clksrc]) / prescaler; | ||
55 | - | ||
56 | - DPRINTF("Setting ptimer frequency to %u\n", s->freq); | ||
57 | - | ||
58 | - if (s->freq) { | ||
59 | - ptimer_set_freq(s->timer_reload, s->freq); | ||
60 | - ptimer_set_freq(s->timer_cmp, s->freq); | ||
61 | - } | ||
62 | + uint32_t clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS); | ||
63 | + uint32_t prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS); | ||
64 | + uint32_t f_in = imx_ccm_get_clock_frequency(s->ccm, imx_epit_clocks[clksrc]); | ||
65 | + uint32_t freq = f_in / prescaler; | ||
66 | + DPRINTF("ptimer frequency is %u\n", freq); | ||
67 | + return freq; | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reset(IMXEPITState *s, bool is_hard_reset) | ||
72 | s->sr = 0; | ||
73 | s->lr = EPIT_TIMER_MAX; | ||
74 | s->cmp = 0; | ||
75 | - s->cnt = 0; | ||
76 | ptimer_transaction_begin(s->timer_cmp); | ||
77 | ptimer_transaction_begin(s->timer_reload); | ||
78 | - /* stop both timers */ | ||
46 | + | 79 | + |
47 | #endif | 80 | + /* |
48 | diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c | 81 | + * The reset switches off the input clock, so even if the CR.EN is still |
49 | index XXXXXXX..XXXXXXX 100644 | 82 | + * set, the timers are no longer running. |
50 | --- a/hw/i386/intel_iommu.c | 83 | + */ |
51 | +++ b/hw/i386/intel_iommu.c | 84 | + assert(imx_epit_get_freq(s) == 0); |
52 | @@ -XXX,XX +XXX,XX @@ | 85 | ptimer_stop(s->timer_cmp); |
53 | #include "hw/i386/x86-iommu.h" | 86 | ptimer_stop(s->timer_reload); |
54 | #include "hw/pci-host/q35.h" | 87 | - /* compute new frequency */ |
55 | #include "sysemu/kvm.h" | 88 | - imx_epit_set_freq(s); |
56 | +#include "sysemu/dma.h" | 89 | /* init both timers to EPIT_TIMER_MAX */ |
57 | #include "sysemu/sysemu.h" | 90 | ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1); |
58 | #include "hw/i386/apic_internal.h" | 91 | ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1); |
59 | #include "kvm/kvm_i386.h" | 92 | - if (s->freq && (s->cr & CR_EN)) { |
60 | @@ -XXX,XX +XXX,XX @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) | 93 | - /* if the timer is still enabled, restart it */ |
61 | return vtd_dev_as; | 94 | - ptimer_run(s->timer_reload, 0); |
95 | - } | ||
96 | ptimer_transaction_commit(s->timer_cmp); | ||
97 | ptimer_transaction_commit(s->timer_reload); | ||
62 | } | 98 | } |
63 | 99 | ||
64 | -static uint64_t get_naturally_aligned_size(uint64_t start, | 100 | -static uint32_t imx_epit_update_count(IMXEPITState *s) |
65 | - uint64_t size, int gaw) | ||
66 | -{ | 101 | -{ |
67 | - uint64_t max_mask = 1ULL << gaw; | 102 | - s->cnt = ptimer_get_count(s->timer_reload); |
68 | - uint64_t alignment = start ? start & -start : max_mask; | ||
69 | - | 103 | - |
70 | - alignment = MIN(alignment, max_mask); | 104 | - return s->cnt; |
71 | - size = MIN(size, max_mask); | ||
72 | - | ||
73 | - if (alignment <= size) { | ||
74 | - /* Increase the alignment of start */ | ||
75 | - return alignment; | ||
76 | - } else { | ||
77 | - /* Find the largest page mask from size */ | ||
78 | - return 1ULL << (63 - clz64(size)); | ||
79 | - } | ||
80 | -} | 105 | -} |
81 | - | 106 | - |
82 | /* Unmap the whole range in the notifier's scope. */ | 107 | static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) |
83 | static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) | ||
84 | { | 108 | { |
85 | @@ -XXX,XX +XXX,XX @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) | 109 | IMXEPITState *s = IMX_EPIT(opaque); |
86 | 110 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) | |
87 | while (remain >= VTD_PAGE_SIZE) { | 111 | break; |
88 | IOMMUTLBEvent event; | 112 | |
89 | - uint64_t mask = get_naturally_aligned_size(start, remain, s->aw_bits); | 113 | case 4: /* CNT */ |
90 | + uint64_t mask = dma_aligned_pow2_mask(start, end, s->aw_bits); | 114 | - imx_epit_update_count(s); |
91 | + uint64_t size = mask + 1; | 115 | - reg_value = s->cnt; |
92 | 116 | + reg_value = ptimer_get_count(s->timer_reload); | |
93 | - assert(mask); | 117 | break; |
94 | + assert(size); | 118 | |
95 | 119 | default: | |
96 | event.type = IOMMU_NOTIFIER_UNMAP; | 120 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s) |
97 | event.entry.iova = start; | 121 | { |
98 | - event.entry.addr_mask = mask - 1; | 122 | if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN)) { |
99 | + event.entry.addr_mask = mask; | 123 | /* if the compare feature is on and timers are running */ |
100 | event.entry.target_as = &address_space_memory; | 124 | - uint32_t tmp = imx_epit_update_count(s); |
101 | event.entry.perm = IOMMU_NONE; | 125 | + uint32_t tmp = ptimer_get_count(s->timer_reload); |
102 | /* This field is meaningless for unmap */ | 126 | uint64_t next; |
103 | @@ -XXX,XX +XXX,XX @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) | 127 | if (tmp > s->cmp) { |
104 | 128 | /* It'll fire in this round of the timer */ | |
105 | memory_region_notify_iommu_one(n, &event); | 129 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s) |
106 | 130 | ||
107 | - start += mask; | 131 | static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
108 | - remain -= mask; | 132 | { |
109 | + start += size; | 133 | + uint32_t freq = 0; |
110 | + remain -= size; | 134 | uint32_t oldcr = s->cr; |
135 | |||
136 | s->cr = value & 0x03ffffff; | ||
137 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) | ||
138 | ptimer_transaction_begin(s->timer_cmp); | ||
139 | ptimer_transaction_begin(s->timer_reload); | ||
140 | |||
141 | - /* Update the frequency. Has been done already in case of a reset. */ | ||
142 | + /* | ||
143 | + * Update the frequency. In case of a reset the input clock was | ||
144 | + * switched off, so this can be skipped. | ||
145 | + */ | ||
146 | if (!(s->cr & CR_SWR)) { | ||
147 | - imx_epit_set_freq(s); | ||
148 | + freq = imx_epit_get_freq(s); | ||
149 | + if (freq) { | ||
150 | + ptimer_set_freq(s->timer_reload, freq); | ||
151 | + ptimer_set_freq(s->timer_cmp, freq); | ||
152 | + } | ||
111 | } | 153 | } |
112 | 154 | ||
113 | assert(!remain); | 155 | - if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { |
114 | diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c | 156 | + if (freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { |
115 | index XXXXXXX..XXXXXXX 100644 | 157 | if (s->cr & CR_ENMOD) { |
116 | --- a/softmmu/dma-helpers.c | 158 | if (s->cr & CR_RLD) { |
117 | +++ b/softmmu/dma-helpers.c | 159 | ptimer_set_limit(s->timer_reload, s->lr, 1); |
118 | @@ -XXX,XX +XXX,XX @@ void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, | 160 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps imx_epit_ops = { |
119 | { | 161 | |
120 | block_acct_start(blk_get_stats(blk), cookie, sg->size, type); | 162 | static const VMStateDescription vmstate_imx_timer_epit = { |
121 | } | 163 | .name = TYPE_IMX_EPIT, |
122 | + | 164 | - .version_id = 2, |
123 | +uint64_t dma_aligned_pow2_mask(uint64_t start, uint64_t end, int max_addr_bits) | 165 | - .minimum_version_id = 2, |
124 | +{ | 166 | + .version_id = 3, |
125 | + uint64_t max_mask = UINT64_MAX, addr_mask = end - start; | 167 | + .minimum_version_id = 3, |
126 | + uint64_t alignment_mask, size_mask; | 168 | .fields = (VMStateField[]) { |
127 | + | 169 | VMSTATE_UINT32(cr, IMXEPITState), |
128 | + if (max_addr_bits != 64) { | 170 | VMSTATE_UINT32(sr, IMXEPITState), |
129 | + max_mask = (1ULL << max_addr_bits) - 1; | 171 | VMSTATE_UINT32(lr, IMXEPITState), |
130 | + } | 172 | VMSTATE_UINT32(cmp, IMXEPITState), |
131 | + | 173 | - VMSTATE_UINT32(cnt, IMXEPITState), |
132 | + alignment_mask = start ? (start & -start) - 1 : max_mask; | 174 | - VMSTATE_UINT32(freq, IMXEPITState), |
133 | + alignment_mask = MIN(alignment_mask, max_mask); | 175 | VMSTATE_PTIMER(timer_reload, IMXEPITState), |
134 | + size_mask = MIN(addr_mask, max_mask); | 176 | VMSTATE_PTIMER(timer_cmp, IMXEPITState), |
135 | + | 177 | VMSTATE_END_OF_LIST() |
136 | + if (alignment_mask <= size_mask) { | ||
137 | + /* Increase the alignment of start */ | ||
138 | + return alignment_mask; | ||
139 | + } else { | ||
140 | + /* Find the largest page mask from size */ | ||
141 | + if (addr_mask == UINT64_MAX) { | ||
142 | + return UINT64_MAX; | ||
143 | + } | ||
144 | + return (1ULL << (63 - clz64(addr_mask + 1))) - 1; | ||
145 | + } | ||
146 | +} | ||
147 | + | ||
148 | -- | 178 | -- |
149 | 2.20.1 | 179 | 2.25.1 |
150 | |||
151 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Unmap notifiers work with an address mask assuming an | 3 | - fix #1263 for CR writes |
4 | invalidation range of a power of 2. Nothing mandates this | 4 | - rework compare time handling |
5 | in the VIRTIO-IOMMU spec. | 5 | - The compare timer has to run even if CR.OCIEN is not set, |
6 | as SR.OCIF must be updated. | ||
7 | - The compare timer fires exactly once when the | ||
8 | compare value is less than the current value, but the | ||
9 | reload values is less than the compare value. | ||
10 | - The compare timer will never fire if the reload value is | ||
11 | less than the compare value. Disable it in this case. | ||
6 | 12 | ||
7 | So in case the range is not a power of 2, split it into | 13 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
8 | several invalidations. | 14 | [PMM: fixed minor style nits] |
9 | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | |
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
12 | Message-id: 20210309102742.30442-4-eric.auger@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 17 | --- |
15 | hw/virtio/virtio-iommu.c | 19 ++++++++++++++++--- | 18 | hw/timer/imx_epit.c | 192 ++++++++++++++++++++++++++------------------ |
16 | 1 file changed, 16 insertions(+), 3 deletions(-) | 19 | 1 file changed, 116 insertions(+), 76 deletions(-) |
17 | 20 | ||
18 | diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c | 21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
19 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/virtio/virtio-iommu.c | 23 | --- a/hw/timer/imx_epit.c |
21 | +++ b/hw/virtio/virtio-iommu.c | 24 | +++ b/hw/timer/imx_epit.c |
22 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, | 25 | @@ -XXX,XX +XXX,XX @@ |
23 | hwaddr virt_end) | 26 | * Originally written by Hans Jiang |
24 | { | 27 | * Updated by Peter Chubb |
25 | IOMMUTLBEvent event; | 28 | * Updated by Jean-Christophe Dubois <jcd@tribudubois.net> |
26 | + uint64_t delta = virt_end - virt_start; | 29 | + * Updated by Axel Heider |
27 | 30 | * | |
28 | if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) { | 31 | * This code is licensed under GPL version 2 or later. See |
29 | return; | 32 | * the COPYING file in the top-level directory. |
30 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, | 33 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) |
31 | 34 | return reg_value; | |
32 | event.type = IOMMU_NOTIFIER_UNMAP; | 35 | } |
33 | event.entry.target_as = &address_space_memory; | 36 | |
34 | - event.entry.addr_mask = virt_end - virt_start; | 37 | -/* Must be called from ptimer_transaction_begin/commit block for s->timer_cmp */ |
35 | - event.entry.iova = virt_start; | 38 | -static void imx_epit_reload_compare_timer(IMXEPITState *s) |
36 | event.entry.perm = IOMMU_NONE; | 39 | +/* |
37 | event.entry.translated_addr = 0; | 40 | + * Must be called from a ptimer_transaction_begin/commit block for |
38 | + event.entry.addr_mask = delta; | 41 | + * s->timer_cmp, but outside of a transaction block of s->timer_reload, |
39 | + event.entry.iova = virt_start; | 42 | + * so the proper counter value is read. |
40 | 43 | + */ | |
41 | - memory_region_notify_iommu(mr, 0, event); | 44 | +static void imx_epit_update_compare_timer(IMXEPITState *s) |
42 | + if (delta == UINT64_MAX) { | 45 | { |
43 | + memory_region_notify_iommu(mr, 0, event); | 46 | - if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN)) { |
47 | - /* if the compare feature is on and timers are running */ | ||
48 | - uint32_t tmp = ptimer_get_count(s->timer_reload); | ||
49 | - uint64_t next; | ||
50 | - if (tmp > s->cmp) { | ||
51 | - /* It'll fire in this round of the timer */ | ||
52 | - next = tmp - s->cmp; | ||
53 | - } else { /* catch it next time around */ | ||
54 | - next = tmp - s->cmp + ((s->cr & CR_RLD) ? EPIT_TIMER_MAX : s->lr); | ||
55 | + uint64_t counter = 0; | ||
56 | + bool is_oneshot = false; | ||
57 | + /* | ||
58 | + * The compare timer only has to run if the timer peripheral is active | ||
59 | + * and there is an input clock, Otherwise it can be switched off. | ||
60 | + */ | ||
61 | + bool is_active = (s->cr & CR_EN) && imx_epit_get_freq(s); | ||
62 | + if (is_active) { | ||
63 | + /* | ||
64 | + * Calculate next timeout for compare timer. Reading the reload | ||
65 | + * counter returns proper results only if pending transactions | ||
66 | + * on it are committed here. Otherwise stale values are be read. | ||
67 | + */ | ||
68 | + counter = ptimer_get_count(s->timer_reload); | ||
69 | + uint64_t limit = ptimer_get_limit(s->timer_cmp); | ||
70 | + /* | ||
71 | + * The compare timer is a periodic timer if the limit is at least | ||
72 | + * the compare value. Otherwise it may fire at most once in the | ||
73 | + * current round. | ||
74 | + */ | ||
75 | + bool is_oneshot = (limit >= s->cmp); | ||
76 | + if (counter >= s->cmp) { | ||
77 | + /* The compare timer fires in the current round. */ | ||
78 | + counter -= s->cmp; | ||
79 | + } else if (!is_oneshot) { | ||
80 | + /* | ||
81 | + * The compare timer fires after a reload, as it is below the | ||
82 | + * compare value already in this round. Note that the counter | ||
83 | + * value calculated below can be above the 32-bit limit, which | ||
84 | + * is legal here because the compare timer is an internal | ||
85 | + * helper ptimer only. | ||
86 | + */ | ||
87 | + counter += limit - s->cmp; | ||
88 | + } else { | ||
89 | + /* | ||
90 | + * The compare timer won't fire in this round, and the limit is | ||
91 | + * set to a value below the compare value. This practically means | ||
92 | + * it will never fire, so it can be switched off. | ||
93 | + */ | ||
94 | + is_active = false; | ||
95 | } | ||
96 | - ptimer_set_count(s->timer_cmp, next); | ||
97 | } | ||
98 | + | ||
99 | + /* | ||
100 | + * Set the compare timer and let it run, or stop it. This is agnostic | ||
101 | + * of CR.OCIEN bit, as this bit affects interrupt generation only. The | ||
102 | + * compare timer needs to run even if no interrupts are to be generated, | ||
103 | + * because the SR.OCIF bit must be updated also. | ||
104 | + * Note that the timer might already be stopped or be running with | ||
105 | + * counter values. However, finding out when an update is needed and | ||
106 | + * when not is not trivial. It's much easier applying the setting again, | ||
107 | + * as this does not harm either and the overhead is negligible. | ||
108 | + */ | ||
109 | + if (is_active) { | ||
110 | + ptimer_set_count(s->timer_cmp, counter); | ||
111 | + ptimer_run(s->timer_cmp, is_oneshot ? 1 : 0); | ||
112 | + } else { | ||
113 | + ptimer_stop(s->timer_cmp); | ||
44 | + } | 114 | + } |
45 | + | 115 | + |
46 | + | 116 | } |
47 | + while (virt_start != virt_end + 1) { | 117 | |
48 | + uint64_t mask = dma_aligned_pow2_mask(virt_start, virt_end, 64); | 118 | static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
49 | + | 119 | { |
50 | + event.entry.addr_mask = mask; | 120 | - uint32_t freq = 0; |
51 | + event.entry.iova = virt_start; | 121 | uint32_t oldcr = s->cr; |
52 | + memory_region_notify_iommu(mr, 0, event); | 122 | |
53 | + virt_start += mask + 1; | 123 | s->cr = value & 0x03ffffff; |
54 | + } | 124 | |
55 | } | 125 | if (s->cr & CR_SWR) { |
56 | 126 | - /* handle the reset */ | |
57 | static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value, | 127 | + /* |
128 | + * Reset clears CR.SWR again. It does not touch CR.EN, but the timers | ||
129 | + * are still stopped because the input clock is disabled. | ||
130 | + */ | ||
131 | imx_epit_reset(s, false); | ||
132 | + } else { | ||
133 | + uint32_t freq; | ||
134 | + uint32_t toggled_cr_bits = oldcr ^ s->cr; | ||
135 | + /* re-initialize the limits if CR.RLD has changed */ | ||
136 | + bool set_limit = toggled_cr_bits & CR_RLD; | ||
137 | + /* set the counter if the timer got just enabled and CR.ENMOD is set */ | ||
138 | + bool is_switched_on = (toggled_cr_bits & s->cr) & CR_EN; | ||
139 | + bool set_counter = is_switched_on && (s->cr & CR_ENMOD); | ||
140 | + | ||
141 | + ptimer_transaction_begin(s->timer_cmp); | ||
142 | + ptimer_transaction_begin(s->timer_reload); | ||
143 | + freq = imx_epit_get_freq(s); | ||
144 | + if (freq) { | ||
145 | + ptimer_set_freq(s->timer_reload, freq); | ||
146 | + ptimer_set_freq(s->timer_cmp, freq); | ||
147 | + } | ||
148 | + | ||
149 | + if (set_limit || set_counter) { | ||
150 | + uint64_t limit = (s->cr & CR_RLD) ? s->lr : EPIT_TIMER_MAX; | ||
151 | + ptimer_set_limit(s->timer_reload, limit, set_counter ? 1 : 0); | ||
152 | + if (set_limit) { | ||
153 | + ptimer_set_limit(s->timer_cmp, limit, 0); | ||
154 | + } | ||
155 | + } | ||
156 | + /* | ||
157 | + * If there is an input clock and the peripheral is enabled, then | ||
158 | + * ensure the wall clock timer is ticking. Otherwise stop the timers. | ||
159 | + * The compare timer will be updated later. | ||
160 | + */ | ||
161 | + if (freq && (s->cr & CR_EN)) { | ||
162 | + ptimer_run(s->timer_reload, 0); | ||
163 | + } else { | ||
164 | + ptimer_stop(s->timer_reload); | ||
165 | + } | ||
166 | + /* Commit changes to reload timer, so they can propagate. */ | ||
167 | + ptimer_transaction_commit(s->timer_reload); | ||
168 | + /* Update compare timer based on the committed reload timer value. */ | ||
169 | + imx_epit_update_compare_timer(s); | ||
170 | + ptimer_transaction_commit(s->timer_cmp); | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) | ||
175 | * - write to CR.EN or CR.OCIE | ||
176 | */ | ||
177 | imx_epit_update_int(s); | ||
178 | - | ||
179 | - /* | ||
180 | - * TODO: could we 'break' here for reset? following operations appear | ||
181 | - * to duplicate the work imx_epit_reset() already did. | ||
182 | - */ | ||
183 | - | ||
184 | - ptimer_transaction_begin(s->timer_cmp); | ||
185 | - ptimer_transaction_begin(s->timer_reload); | ||
186 | - | ||
187 | - /* | ||
188 | - * Update the frequency. In case of a reset the input clock was | ||
189 | - * switched off, so this can be skipped. | ||
190 | - */ | ||
191 | - if (!(s->cr & CR_SWR)) { | ||
192 | - freq = imx_epit_get_freq(s); | ||
193 | - if (freq) { | ||
194 | - ptimer_set_freq(s->timer_reload, freq); | ||
195 | - ptimer_set_freq(s->timer_cmp, freq); | ||
196 | - } | ||
197 | - } | ||
198 | - | ||
199 | - if (freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { | ||
200 | - if (s->cr & CR_ENMOD) { | ||
201 | - if (s->cr & CR_RLD) { | ||
202 | - ptimer_set_limit(s->timer_reload, s->lr, 1); | ||
203 | - ptimer_set_limit(s->timer_cmp, s->lr, 1); | ||
204 | - } else { | ||
205 | - ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1); | ||
206 | - ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1); | ||
207 | - } | ||
208 | - } | ||
209 | - | ||
210 | - imx_epit_reload_compare_timer(s); | ||
211 | - ptimer_run(s->timer_reload, 0); | ||
212 | - if (s->cr & CR_OCIEN) { | ||
213 | - ptimer_run(s->timer_cmp, 0); | ||
214 | - } else { | ||
215 | - ptimer_stop(s->timer_cmp); | ||
216 | - } | ||
217 | - } else if (!(s->cr & CR_EN)) { | ||
218 | - /* stop both timers */ | ||
219 | - ptimer_stop(s->timer_reload); | ||
220 | - ptimer_stop(s->timer_cmp); | ||
221 | - } else if (s->cr & CR_OCIEN) { | ||
222 | - if (!(oldcr & CR_OCIEN)) { | ||
223 | - imx_epit_reload_compare_timer(s); | ||
224 | - ptimer_run(s->timer_cmp, 0); | ||
225 | - } | ||
226 | - } else { | ||
227 | - ptimer_stop(s->timer_cmp); | ||
228 | - } | ||
229 | - | ||
230 | - ptimer_transaction_commit(s->timer_cmp); | ||
231 | - ptimer_transaction_commit(s->timer_reload); | ||
232 | } | ||
233 | |||
234 | static void imx_epit_write_sr(IMXEPITState *s, uint32_t value) | ||
235 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write_lr(IMXEPITState *s, uint32_t value) | ||
236 | /* If IOVW bit is set then set the timer value */ | ||
237 | ptimer_set_count(s->timer_reload, s->lr); | ||
238 | } | ||
239 | - /* | ||
240 | - * Commit the change to s->timer_reload, so it can propagate. Otherwise | ||
241 | - * the timer interrupt may not fire properly. The commit must happen | ||
242 | - * before calling imx_epit_reload_compare_timer(), which reads | ||
243 | - * s->timer_reload internally again. | ||
244 | - */ | ||
245 | + /* Commit the changes to s->timer_reload, so they can propagate. */ | ||
246 | ptimer_transaction_commit(s->timer_reload); | ||
247 | - imx_epit_reload_compare_timer(s); | ||
248 | + /* Update the compare timer based on the committed reload timer value. */ | ||
249 | + imx_epit_update_compare_timer(s); | ||
250 | ptimer_transaction_commit(s->timer_cmp); | ||
251 | } | ||
252 | |||
253 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cmp(IMXEPITState *s, uint32_t value) | ||
254 | { | ||
255 | s->cmp = value; | ||
256 | |||
257 | + /* Update the compare timer based on the committed reload timer value. */ | ||
258 | ptimer_transaction_begin(s->timer_cmp); | ||
259 | - imx_epit_reload_compare_timer(s); | ||
260 | + imx_epit_update_compare_timer(s); | ||
261 | ptimer_transaction_commit(s->timer_cmp); | ||
262 | } | ||
263 | |||
264 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_cmp(void *opaque) | ||
265 | { | ||
266 | IMXEPITState *s = IMX_EPIT(opaque); | ||
267 | |||
268 | + /* The cmp ptimer can't be running when the peripheral is disabled */ | ||
269 | + assert(s->cr & CR_EN); | ||
270 | + | ||
271 | DPRINTF("sr was %d\n", s->sr); | ||
272 | /* Set interrupt status bit SR.OCIF and update the interrupt state */ | ||
273 | s->sr |= SR_OCIF; | ||
58 | -- | 274 | -- |
59 | 2.20.1 | 275 | 2.25.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Wrote too much with low-half zip (zip1) with vl % 512 != 0. | 3 | Fix these: |
4 | 4 | ||
5 | Adjust all of the x + (y << s) to x | (y << s) as a style fix. | 5 | WARNING: Block comments use a leading /* on a separate line |
6 | WARNING: Block comments use * on subsequent lines | ||
7 | WARNING: Block comments use a trailing */ on a separate line | ||
6 | 8 | ||
7 | We only ever have exact overlap between D, M, and N. Therefore | 9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
8 | we only need a single temporary, and we do not need to check for | 10 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
9 | partial overlap. | 11 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
10 | 12 | Message-id: 20221213190537.511-2-farosas@suse.de | |
11 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210309155305.11301-3-richard.henderson@linaro.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 14 | --- |
17 | target/arm/sve_helper.c | 25 ++++++++++++++----------- | 15 | target/arm/helper.c | 323 +++++++++++++++++++++++++++++--------------- |
18 | 1 file changed, 14 insertions(+), 11 deletions(-) | 16 | 1 file changed, 215 insertions(+), 108 deletions(-) |
19 | 17 | ||
20 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 18 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/sve_helper.c | 20 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/sve_helper.c | 21 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | 22 | @@ -XXX,XX +XXX,XX @@ uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri) |
25 | intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | 23 | static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, |
26 | int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); | 24 | uint64_t v) |
27 | intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA); | 25 | { |
28 | + int esize = 1 << esz; | 26 | - /* Raw write of a coprocessor register (as needed for migration, etc). |
29 | uint64_t *d = vd; | 27 | + /* |
30 | intptr_t i; | 28 | + * Raw write of a coprocessor register (as needed for migration, etc). |
31 | 29 | * Note that constant registers are treated as write-ignored; the | |
32 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | 30 | * caller should check for success by whether a readback gives the |
33 | mm = extract64(mm, high * half, half); | 31 | * value written. |
34 | nn = expand_bits(nn, esz); | 32 | @@ -XXX,XX +XXX,XX @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, |
35 | mm = expand_bits(mm, esz); | 33 | |
36 | - d[0] = nn + (mm << (1 << esz)); | 34 | static bool raw_accessors_invalid(const ARMCPRegInfo *ri) |
37 | + d[0] = nn | (mm << esize); | 35 | { |
36 | - /* Return true if the regdef would cause an assertion if you called | ||
37 | + /* | ||
38 | + * Return true if the regdef would cause an assertion if you called | ||
39 | * read_raw_cp_reg() or write_raw_cp_reg() on it (ie if it is a | ||
40 | * program bug for it not to have the NO_RAW flag). | ||
41 | * NB that returning false here doesn't necessarily mean that calling | ||
42 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu) | ||
43 | if (ri->type & ARM_CP_NO_RAW) { | ||
44 | continue; | ||
45 | } | ||
46 | - /* Write value and confirm it reads back as written | ||
47 | + /* | ||
48 | + * Write value and confirm it reads back as written | ||
49 | * (to catch read-only registers and partially read-only | ||
50 | * registers where the incoming migration value doesn't match) | ||
51 | */ | ||
52 | @@ -XXX,XX +XXX,XX @@ static gint cpreg_key_compare(gconstpointer a, gconstpointer b) | ||
53 | |||
54 | void init_cpreg_list(ARMCPU *cpu) | ||
55 | { | ||
56 | - /* Initialise the cpreg_tuples[] array based on the cp_regs hash. | ||
57 | + /* | ||
58 | + * Initialise the cpreg_tuples[] array based on the cp_regs hash. | ||
59 | * Note that we require cpreg_tuples[] to be sorted by key ID. | ||
60 | */ | ||
61 | GList *keys; | ||
62 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_el3_aa32ns(CPUARMState *env, | ||
63 | return CP_ACCESS_OK; | ||
64 | } | ||
65 | |||
66 | -/* Some secure-only AArch32 registers trap to EL3 if used from | ||
67 | +/* | ||
68 | + * Some secure-only AArch32 registers trap to EL3 if used from | ||
69 | * Secure EL1 (but are just ordinary UNDEF in other non-EL3 contexts). | ||
70 | * Note that an access from Secure EL1 can only happen if EL3 is AArch64. | ||
71 | * We assume that the .access field is set to PL1_RW. | ||
72 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_trap_aa32s_el1(CPUARMState *env, | ||
73 | return CP_ACCESS_TRAP_UNCATEGORIZED; | ||
74 | } | ||
75 | |||
76 | -/* Check for traps to performance monitor registers, which are controlled | ||
77 | +/* | ||
78 | + * Check for traps to performance monitor registers, which are controlled | ||
79 | * by MDCR_EL2.TPM for EL2 and MDCR_EL3.TPM for EL3. | ||
80 | */ | ||
81 | static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
82 | @@ -XXX,XX +XXX,XX @@ static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
83 | ARMCPU *cpu = env_archcpu(env); | ||
84 | |||
85 | if (raw_read(env, ri) != value) { | ||
86 | - /* Unlike real hardware the qemu TLB uses virtual addresses, | ||
87 | + /* | ||
88 | + * Unlike real hardware the qemu TLB uses virtual addresses, | ||
89 | * not modified virtual addresses, so this causes a TLB flush. | ||
90 | */ | ||
91 | tlb_flush(CPU(cpu)); | ||
92 | @@ -XXX,XX +XXX,XX @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
93 | |||
94 | if (raw_read(env, ri) != value && !arm_feature(env, ARM_FEATURE_PMSA) | ||
95 | && !extended_addresses_enabled(env)) { | ||
96 | - /* For VMSA (when not using the LPAE long descriptor page table | ||
97 | + /* | ||
98 | + * For VMSA (when not using the LPAE long descriptor page table | ||
99 | * format) this register includes the ASID, so do a TLB flush. | ||
100 | * For PMSA it is purely a process ID and no action is needed. | ||
101 | */ | ||
102 | @@ -XXX,XX +XXX,XX @@ static void tlbiipas2is_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
103 | } | ||
104 | |||
105 | static const ARMCPRegInfo cp_reginfo[] = { | ||
106 | - /* Define the secure and non-secure FCSE identifier CP registers | ||
107 | + /* | ||
108 | + * Define the secure and non-secure FCSE identifier CP registers | ||
109 | * separately because there is no secure bank in V8 (no _EL3). This allows | ||
110 | * the secure register to be properly reset and migrated. There is also no | ||
111 | * v8 EL1 version of the register so the non-secure instance stands alone. | ||
112 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
113 | .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, | ||
114 | .fieldoffset = offsetof(CPUARMState, cp15.fcseidr_s), | ||
115 | .resetvalue = 0, .writefn = fcse_write, .raw_writefn = raw_write, }, | ||
116 | - /* Define the secure and non-secure context identifier CP registers | ||
117 | + /* | ||
118 | + * Define the secure and non-secure context identifier CP registers | ||
119 | * separately because there is no secure bank in V8 (no _EL3). This allows | ||
120 | * the secure register to be properly reset and migrated. In the | ||
121 | * non-secure case, the 32-bit register will have reset and migration | ||
122 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
123 | }; | ||
124 | |||
125 | static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
126 | - /* NB: Some of these registers exist in v8 but with more precise | ||
127 | + /* | ||
128 | + * NB: Some of these registers exist in v8 but with more precise | ||
129 | * definitions that don't use CP_ANY wildcards (mostly in v8_cp_reginfo[]). | ||
130 | */ | ||
131 | /* MMU Domain access control / MPU write buffer control */ | ||
132 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
133 | .writefn = dacr_write, .raw_writefn = raw_write, | ||
134 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dacr_s), | ||
135 | offsetoflow32(CPUARMState, cp15.dacr_ns) } }, | ||
136 | - /* ARMv7 allocates a range of implementation defined TLB LOCKDOWN regs. | ||
137 | + /* | ||
138 | + * ARMv7 allocates a range of implementation defined TLB LOCKDOWN regs. | ||
139 | * For v6 and v5, these mappings are overly broad. | ||
140 | */ | ||
141 | { .name = "TLB_LOCKDOWN", .cp = 15, .crn = 10, .crm = 0, | ||
142 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
143 | }; | ||
144 | |||
145 | static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
146 | - /* Not all pre-v6 cores implemented this WFI, so this is slightly | ||
147 | + /* | ||
148 | + * Not all pre-v6 cores implemented this WFI, so this is slightly | ||
149 | * over-broad. | ||
150 | */ | ||
151 | { .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2, | ||
152 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = { | ||
153 | }; | ||
154 | |||
155 | static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
156 | - /* Standard v6 WFI (also used in some pre-v6 cores); not in v7 (which | ||
157 | + /* | ||
158 | + * Standard v6 WFI (also used in some pre-v6 cores); not in v7 (which | ||
159 | * is UNPREDICTABLE; we choose to NOP as most implementations do). | ||
160 | */ | ||
161 | { .name = "WFI_v6", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4, | ||
162 | .access = PL1_W, .type = ARM_CP_WFI }, | ||
163 | - /* L1 cache lockdown. Not architectural in v6 and earlier but in practice | ||
164 | + /* | ||
165 | + * L1 cache lockdown. Not architectural in v6 and earlier but in practice | ||
166 | * implemented in 926, 946, 1026, 1136, 1176 and 11MPCore. StrongARM and | ||
167 | * OMAPCP will override this space. | ||
168 | */ | ||
169 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = { | ||
170 | { .name = "DUMMY", .cp = 15, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = CP_ANY, | ||
171 | .access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW, | ||
172 | .resetvalue = 0 }, | ||
173 | - /* We don't implement pre-v7 debug but most CPUs had at least a DBGDIDR; | ||
174 | + /* | ||
175 | + * We don't implement pre-v7 debug but most CPUs had at least a DBGDIDR; | ||
176 | * implementing it as RAZ means the "debug architecture version" bits | ||
177 | * will read as a reserved value, which should cause Linux to not try | ||
178 | * to use the debug hardware. | ||
179 | */ | ||
180 | { .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
181 | .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
182 | - /* MMU TLB control. Note that the wildcarding means we cover not just | ||
183 | + /* | ||
184 | + * MMU TLB control. Note that the wildcarding means we cover not just | ||
185 | * the unified TLB ops but also the dside/iside/inner-shareable variants. | ||
186 | */ | ||
187 | { .name = "TLBIALL", .cp = 15, .crn = 8, .crm = CP_ANY, | ||
188 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
189 | |||
190 | /* In ARMv8 most bits of CPACR_EL1 are RES0. */ | ||
191 | if (!arm_feature(env, ARM_FEATURE_V8)) { | ||
192 | - /* ARMv7 defines bits for unimplemented coprocessors as RAZ/WI. | ||
193 | + /* | ||
194 | + * ARMv7 defines bits for unimplemented coprocessors as RAZ/WI. | ||
195 | * ASEDIS [31] and D32DIS [30] are both UNK/SBZP without VFP. | ||
196 | * TRCDIS [28] is RAZ/WI since we do not implement a trace macrocell. | ||
197 | */ | ||
198 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
199 | value |= R_CPACR_ASEDIS_MASK; | ||
200 | } | ||
201 | |||
202 | - /* VFPv3 and upwards with NEON implement 32 double precision | ||
203 | + /* | ||
204 | + * VFPv3 and upwards with NEON implement 32 double precision | ||
205 | * registers (D0-D31). | ||
206 | */ | ||
207 | if (!cpu_isar_feature(aa32_simd_r32, env_archcpu(env))) { | ||
208 | @@ -XXX,XX +XXX,XX @@ static uint64_t cpacr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
209 | |||
210 | static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri) | ||
211 | { | ||
212 | - /* Call cpacr_write() so that we reset with the correct RAO bits set | ||
213 | + /* | ||
214 | + * Call cpacr_write() so that we reset with the correct RAO bits set | ||
215 | * for our CPU features. | ||
216 | */ | ||
217 | cpacr_write(env, ri, 0); | ||
218 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
219 | { .name = "MVA_prefetch", | ||
220 | .cp = 15, .crn = 7, .crm = 13, .opc1 = 0, .opc2 = 1, | ||
221 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
222 | - /* We need to break the TB after ISB to execute self-modifying code | ||
223 | + /* | ||
224 | + * We need to break the TB after ISB to execute self-modifying code | ||
225 | * correctly and also to take any pending interrupts immediately. | ||
226 | * So use arm_cp_write_ignore() function instead of ARM_CP_NOP flag. | ||
227 | */ | ||
228 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
229 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ifar_s), | ||
230 | offsetof(CPUARMState, cp15.ifar_ns) }, | ||
231 | .resetvalue = 0, }, | ||
232 | - /* Watchpoint Fault Address Register : should actually only be present | ||
233 | + /* | ||
234 | + * Watchpoint Fault Address Register : should actually only be present | ||
235 | * for 1136, 1176, 11MPCore. | ||
236 | */ | ||
237 | { .name = "WFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, | ||
238 | @@ -XXX,XX +XXX,XX @@ static bool event_supported(uint16_t number) | ||
239 | static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
240 | bool isread) | ||
241 | { | ||
242 | - /* Performance monitor registers user accessibility is controlled | ||
243 | + /* | ||
244 | + * Performance monitor registers user accessibility is controlled | ||
245 | * by PMUSERENR. MDCR_EL2.TPM and MDCR_EL3.TPM allow configurable | ||
246 | * trapping to EL2 or EL3 for other accesses. | ||
247 | */ | ||
248 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access_ccntr(CPUARMState *env, | ||
249 | (MDCR_HPME | MDCR_HPMD | MDCR_HPMN | MDCR_HCCD | MDCR_HLP) | ||
250 | #define MDCR_EL3_PMU_ENABLE_BITS (MDCR_SPME | MDCR_SCCD) | ||
251 | |||
252 | -/* Returns true if the counter (pass 31 for PMCCNTR) should count events using | ||
253 | +/* | ||
254 | + * Returns true if the counter (pass 31 for PMCCNTR) should count events using | ||
255 | * the current EL, security state, and register configuration. | ||
256 | */ | ||
257 | static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) | ||
258 | @@ -XXX,XX +XXX,XX @@ static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
259 | static void pmselr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
260 | uint64_t value) | ||
261 | { | ||
262 | - /* The value of PMSELR.SEL affects the behavior of PMXEVTYPER and | ||
263 | + /* | ||
264 | + * The value of PMSELR.SEL affects the behavior of PMXEVTYPER and | ||
265 | * PMXEVCNTR. We allow [0..31] to be written to PMSELR here; in the | ||
266 | * meanwhile, we check PMSELR.SEL when PMXEVTYPER and PMXEVCNTR are | ||
267 | * accessed. | ||
268 | @@ -XXX,XX +XXX,XX @@ static void pmevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
269 | env->cp15.c14_pmevtyper[counter] = value & PMXEVTYPER_MASK; | ||
270 | pmevcntr_op_finish(env, counter); | ||
271 | } | ||
272 | - /* Attempts to access PMXEVTYPER are CONSTRAINED UNPREDICTABLE when | ||
273 | + /* | ||
274 | + * Attempts to access PMXEVTYPER are CONSTRAINED UNPREDICTABLE when | ||
275 | * PMSELR value is equal to or greater than the number of implemented | ||
276 | * counters, but not equal to 0x1f. We opt to behave as a RAZ/WI. | ||
277 | */ | ||
278 | @@ -XXX,XX +XXX,XX @@ static uint64_t pmevcntr_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
279 | } | ||
280 | return ret; | ||
38 | } else { | 281 | } else { |
39 | - ARMPredicateReg tmp_n, tmp_m; | 282 | - /* We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR |
40 | + ARMPredicateReg tmp; | 283 | - * are CONSTRAINED UNPREDICTABLE. */ |
41 | 284 | + /* | |
42 | /* We produce output faster than we consume input. | 285 | + * We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR |
43 | Therefore we must be mindful of possible overlap. */ | 286 | + * are CONSTRAINED UNPREDICTABLE. |
44 | - if ((vn - vd) < (uintptr_t)oprsz) { | 287 | + */ |
45 | - vn = memcpy(&tmp_n, vn, oprsz); | 288 | return 0; |
46 | - } | 289 | } |
47 | - if ((vm - vd) < (uintptr_t)oprsz) { | 290 | } |
48 | - vm = memcpy(&tmp_m, vm, oprsz); | 291 | @@ -XXX,XX +XXX,XX @@ static void pmintenclr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
49 | + if (vd == vn) { | 292 | static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
50 | + vn = memcpy(&tmp, vn, oprsz); | 293 | uint64_t value) |
51 | + if (vd == vm) { | 294 | { |
52 | + vm = vn; | 295 | - /* Note that even though the AArch64 view of this register has bits |
53 | + } | 296 | + /* |
54 | + } else if (vd == vm) { | 297 | + * Note that even though the AArch64 view of this register has bits |
55 | + vm = memcpy(&tmp, vm, oprsz); | 298 | * [10:0] all RES0 we can only mask the bottom 5, to comply with the |
299 | * architectural requirements for bits which are RES0 only in some | ||
300 | * contexts. (ARMv8 would permit us to do no masking at all, but ARMv7 | ||
301 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
302 | if (!arm_feature(env, ARM_FEATURE_EL2)) { | ||
303 | valid_mask &= ~SCR_HCE; | ||
304 | |||
305 | - /* On ARMv7, SMD (or SCD as it is called in v7) is only | ||
306 | + /* | ||
307 | + * On ARMv7, SMD (or SCD as it is called in v7) is only | ||
308 | * supported if EL2 exists. The bit is UNK/SBZP when | ||
309 | * EL2 is unavailable. In QEMU ARMv7, we force it to always zero | ||
310 | * when EL2 is unavailable. | ||
311 | @@ -XXX,XX +XXX,XX @@ static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
312 | { | ||
313 | ARMCPU *cpu = env_archcpu(env); | ||
314 | |||
315 | - /* Acquire the CSSELR index from the bank corresponding to the CCSIDR | ||
316 | + /* | ||
317 | + * Acquire the CSSELR index from the bank corresponding to the CCSIDR | ||
318 | * bank | ||
319 | */ | ||
320 | uint32_t index = A32_BANKED_REG_GET(env, csselr, | ||
321 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
322 | /* the old v6 WFI, UNPREDICTABLE in v7 but we choose to NOP */ | ||
323 | { .name = "NOP", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4, | ||
324 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
325 | - /* Performance monitors are implementation defined in v7, | ||
326 | + /* | ||
327 | + * Performance monitors are implementation defined in v7, | ||
328 | * but with an ARM recommended set of registers, which we | ||
329 | * follow. | ||
330 | * | ||
331 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
332 | .writefn = csselr_write, .resetvalue = 0, | ||
333 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s), | ||
334 | offsetof(CPUARMState, cp15.csselr_ns) } }, | ||
335 | - /* Auxiliary ID register: this actually has an IMPDEF value but for now | ||
336 | + /* | ||
337 | + * Auxiliary ID register: this actually has an IMPDEF value but for now | ||
338 | * just RAZ for all cores: | ||
339 | */ | ||
340 | { .name = "AIDR", .state = ARM_CP_STATE_BOTH, | ||
341 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
342 | .access = PL1_R, .type = ARM_CP_CONST, | ||
343 | .accessfn = access_aa64_tid1, | ||
344 | .resetvalue = 0 }, | ||
345 | - /* Auxiliary fault status registers: these also are IMPDEF, and we | ||
346 | + /* | ||
347 | + * Auxiliary fault status registers: these also are IMPDEF, and we | ||
348 | * choose to RAZ/WI for all cores. | ||
349 | */ | ||
350 | { .name = "AFSR0_EL1", .state = ARM_CP_STATE_BOTH, | ||
351 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
352 | .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 1, | ||
353 | .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
354 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
355 | - /* MAIR can just read-as-written because we don't implement caches | ||
356 | + /* | ||
357 | + * MAIR can just read-as-written because we don't implement caches | ||
358 | * and so don't need to care about memory attributes. | ||
359 | */ | ||
360 | { .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64, | ||
361 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
362 | .opc0 = 3, .opc1 = 6, .crn = 10, .crm = 2, .opc2 = 0, | ||
363 | .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mair_el[3]), | ||
364 | .resetvalue = 0 }, | ||
365 | - /* For non-long-descriptor page tables these are PRRR and NMRR; | ||
366 | + /* | ||
367 | + * For non-long-descriptor page tables these are PRRR and NMRR; | ||
368 | * regardless they still act as reads-as-written for QEMU. | ||
369 | */ | ||
370 | - /* MAIR0/1 are defined separately from their 64-bit counterpart which | ||
371 | + /* | ||
372 | + * MAIR0/1 are defined separately from their 64-bit counterpart which | ||
373 | * allows them to assign the correct fieldoffset based on the endianness | ||
374 | * handled in the field definitions. | ||
375 | */ | ||
376 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
377 | static CPAccessResult gt_cntfrq_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
378 | bool isread) | ||
379 | { | ||
380 | - /* CNTFRQ: not visible from PL0 if both PL0PCTEN and PL0VCTEN are zero. | ||
381 | + /* | ||
382 | + * CNTFRQ: not visible from PL0 if both PL0PCTEN and PL0VCTEN are zero. | ||
383 | * Writable only at the highest implemented exception level. | ||
384 | */ | ||
385 | int el = arm_current_el(env); | ||
386 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_stimer_access(CPUARMState *env, | ||
387 | const ARMCPRegInfo *ri, | ||
388 | bool isread) | ||
389 | { | ||
390 | - /* The AArch64 register view of the secure physical timer is | ||
391 | + /* | ||
392 | + * The AArch64 register view of the secure physical timer is | ||
393 | * always accessible from EL3, and configurably accessible from | ||
394 | * Secure EL1. | ||
395 | */ | ||
396 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
397 | ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx]; | ||
398 | |||
399 | if (gt->ctl & 1) { | ||
400 | - /* Timer enabled: calculate and set current ISTATUS, irq, and | ||
401 | + /* | ||
402 | + * Timer enabled: calculate and set current ISTATUS, irq, and | ||
403 | * reset timer to when ISTATUS next has to change | ||
404 | */ | ||
405 | uint64_t offset = timeridx == GTIMER_VIRT ? | ||
406 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
407 | /* Next transition is when we hit cval */ | ||
408 | nexttick = gt->cval + offset; | ||
56 | } | 409 | } |
57 | if (high) { | 410 | - /* Note that the desired next expiry time might be beyond the |
58 | high = oprsz >> 1; | 411 | + /* |
59 | } | 412 | + * Note that the desired next expiry time might be beyond the |
60 | 413 | * signed-64-bit range of a QEMUTimer -- in this case we just | |
61 | - if ((high & 3) == 0) { | 414 | * set the timer for as far in the future as possible. When the |
62 | + if ((oprsz & 7) == 0) { | 415 | * timer expires we will reset the timer for any remaining period. |
63 | uint32_t *n = vn, *m = vm; | 416 | @@ -XXX,XX +XXX,XX @@ static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
64 | high >>= 2; | 417 | /* Enable toggled */ |
65 | 418 | gt_recalc_timer(cpu, timeridx); | |
66 | - for (i = 0; i < DIV_ROUND_UP(oprsz, 8); i++) { | 419 | } else if ((oldval ^ value) & 2) { |
67 | + for (i = 0; i < oprsz / 8; i++) { | 420 | - /* IMASK toggled: don't need to recalculate, |
68 | uint64_t nn = n[H4(high + i)]; | 421 | + /* |
69 | uint64_t mm = m[H4(high + i)]; | 422 | + * IMASK toggled: don't need to recalculate, |
70 | 423 | * just set the interrupt line based on ISTATUS | |
71 | nn = expand_bits(nn, esz); | 424 | */ |
72 | mm = expand_bits(mm, esz); | 425 | int irqstate = (oldval & 4) && !(value & 2); |
73 | - d[i] = nn + (mm << (1 << esz)); | 426 | @@ -XXX,XX +XXX,XX @@ static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaque) |
74 | + d[i] = nn | (mm << esize); | 427 | } |
75 | } | 428 | |
76 | } else { | 429 | static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
77 | uint8_t *n = vn, *m = vm; | 430 | - /* Note that CNTFRQ is purely reads-as-written for the benefit |
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | 431 | + /* |
79 | 432 | + * Note that CNTFRQ is purely reads-as-written for the benefit | |
80 | nn = expand_bits(nn, esz); | 433 | * of software; writing it doesn't actually change the timer frequency. |
81 | mm = expand_bits(mm, esz); | 434 | * Our reset value matches the fixed frequency we implement the timer at. |
82 | - d16[H2(i)] = nn + (mm << (1 << esz)); | 435 | */ |
83 | + d16[H2(i)] = nn | (mm << esize); | 436 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
437 | .readfn = gt_virt_redir_cval_read, .raw_readfn = raw_read, | ||
438 | .writefn = gt_virt_redir_cval_write, .raw_writefn = raw_write, | ||
439 | }, | ||
440 | - /* Secure timer -- this is actually restricted to only EL3 | ||
441 | + /* | ||
442 | + * Secure timer -- this is actually restricted to only EL3 | ||
443 | * and configurably Secure-EL1 via the accessfn. | ||
444 | */ | ||
445 | { .name = "CNTPS_TVAL_EL1", .state = ARM_CP_STATE_AA64, | ||
446 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
447 | |||
448 | #else | ||
449 | |||
450 | -/* In user-mode most of the generic timer registers are inaccessible | ||
451 | +/* | ||
452 | + * In user-mode most of the generic timer registers are inaccessible | ||
453 | * however modern kernels (4.12+) allow access to cntvct_el0 | ||
454 | */ | ||
455 | |||
456 | @@ -XXX,XX +XXX,XX @@ static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
457 | { | ||
458 | ARMCPU *cpu = env_archcpu(env); | ||
459 | |||
460 | - /* Currently we have no support for QEMUTimer in linux-user so we | ||
461 | + /* | ||
462 | + * Currently we have no support for QEMUTimer in linux-user so we | ||
463 | * can't call gt_get_countervalue(env), instead we directly | ||
464 | * call the lower level functions. | ||
465 | */ | ||
466 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
467 | bool isread) | ||
468 | { | ||
469 | if (ri->opc2 & 4) { | ||
470 | - /* The ATS12NSO* operations must trap to EL3 or EL2 if executed in | ||
471 | + /* | ||
472 | + * The ATS12NSO* operations must trap to EL3 or EL2 if executed in | ||
473 | * Secure EL1 (which can only happen if EL3 is AArch64). | ||
474 | * They are simply UNDEF if executed from NS EL1. | ||
475 | * They function normally from EL2 or EL3. | ||
476 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, | ||
84 | } | 477 | } |
85 | } | 478 | } |
86 | } | 479 | } else { |
480 | - /* fsr is a DFSR/IFSR value for the short descriptor | ||
481 | + /* | ||
482 | + * fsr is a DFSR/IFSR value for the short descriptor | ||
483 | * translation table format (with WnR always clear). | ||
484 | * Convert it to a 32-bit PAR. | ||
485 | */ | ||
486 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav8r_cp_reginfo[] = { | ||
487 | }; | ||
488 | |||
489 | static const ARMCPRegInfo pmsav7_cp_reginfo[] = { | ||
490 | - /* Reset for all these registers is handled in arm_cpu_reset(), | ||
491 | + /* | ||
492 | + * Reset for all these registers is handled in arm_cpu_reset(), | ||
493 | * because the PMSAv7 is also used by M-profile CPUs, which do | ||
494 | * not register cpregs but still need the state to be reset. | ||
495 | */ | ||
496 | @@ -XXX,XX +XXX,XX @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
497 | } | ||
498 | |||
499 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
500 | - /* With LPAE the TTBCR could result in a change of ASID | ||
501 | + /* | ||
502 | + * With LPAE the TTBCR could result in a change of ASID | ||
503 | * via the TTBCR.A1 bit, so do a TLB flush. | ||
504 | */ | ||
505 | tlb_flush(CPU(cpu)); | ||
506 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
507 | offsetoflow32(CPUARMState, cp15.tcr_el[1])} }, | ||
508 | }; | ||
509 | |||
510 | -/* Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
511 | +/* | ||
512 | + * Note that unlike TTBCR, writing to TTBCR2 does not require flushing | ||
513 | * qemu tlbs nor adjusting cached masks. | ||
514 | */ | ||
515 | static const ARMCPRegInfo ttbcr2_reginfo = { | ||
516 | @@ -XXX,XX +XXX,XX @@ static void omap_wfi_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
517 | static void omap_cachemaint_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
518 | uint64_t value) | ||
519 | { | ||
520 | - /* On OMAP there are registers indicating the max/min index of dcache lines | ||
521 | + /* | ||
522 | + * On OMAP there are registers indicating the max/min index of dcache lines | ||
523 | * containing a dirty line; cache flush operations have to reset these. | ||
524 | */ | ||
525 | env->cp15.c15_i_max = 0x000; | ||
526 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = { | ||
527 | .crm = 8, .opc1 = 0, .opc2 = 0, .access = PL1_RW, | ||
528 | .type = ARM_CP_NO_RAW, | ||
529 | .readfn = arm_cp_read_zero, .writefn = omap_wfi_write, }, | ||
530 | - /* TODO: Peripheral port remap register: | ||
531 | + /* | ||
532 | + * TODO: Peripheral port remap register: | ||
533 | * On OMAP2 mcr p15, 0, rn, c15, c2, 4 sets up the interrupt controller | ||
534 | * base address at $rn & ~0xfff and map size of 0x200 << ($rn & 0xfff), | ||
535 | * when MMU is off. | ||
536 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = { | ||
537 | .cp = 15, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_RW, | ||
538 | .fieldoffset = offsetof(CPUARMState, cp15.c1_xscaleauxcr), | ||
539 | .resetvalue = 0, }, | ||
540 | - /* XScale specific cache-lockdown: since we have no cache we NOP these | ||
541 | + /* | ||
542 | + * XScale specific cache-lockdown: since we have no cache we NOP these | ||
543 | * and hope the guest does not really rely on cache behaviour. | ||
544 | */ | ||
545 | { .name = "XSCALE_LOCK_ICACHE_LINE", | ||
546 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = { | ||
547 | }; | ||
548 | |||
549 | static const ARMCPRegInfo dummy_c15_cp_reginfo[] = { | ||
550 | - /* RAZ/WI the whole crn=15 space, when we don't have a more specific | ||
551 | + /* | ||
552 | + * RAZ/WI the whole crn=15 space, when we don't have a more specific | ||
553 | * implementation of this implementation-defined space. | ||
554 | * Ideally this should eventually disappear in favour of actually | ||
555 | * implementing the correct behaviour for all cores. | ||
556 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
557 | }; | ||
558 | |||
559 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
560 | - /* The cache test-and-clean instructions always return (1 << 30) | ||
561 | + /* | ||
562 | + * The cache test-and-clean instructions always return (1 << 30) | ||
563 | * to indicate that there are no dirty cache lines. | ||
564 | */ | ||
565 | { .name = "TC_DCACHE", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 3, | ||
566 | @@ -XXX,XX +XXX,XX @@ static uint64_t mpidr_read_val(CPUARMState *env) | ||
567 | |||
568 | if (arm_feature(env, ARM_FEATURE_V7MP)) { | ||
569 | mpidr |= (1U << 31); | ||
570 | - /* Cores which are uniprocessor (non-coherent) | ||
571 | + /* | ||
572 | + * Cores which are uniprocessor (non-coherent) | ||
573 | * but still implement the MP extensions set | ||
574 | * bit 30. (For instance, Cortex-R5). | ||
575 | */ | ||
576 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tocu(CPUARMState *env, const ARMCPRegInfo *ri, | ||
577 | return do_cacheop_pou_access(env, HCR_TOCU | HCR_TPU); | ||
578 | } | ||
579 | |||
580 | -/* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions | ||
581 | +/* | ||
582 | + * See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions | ||
583 | * Page D4-1736 (DDI0487A.b) | ||
584 | */ | ||
585 | |||
586 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
587 | static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
588 | uint64_t value) | ||
589 | { | ||
590 | - /* Invalidate by VA, EL2 | ||
591 | + /* | ||
592 | + * Invalidate by VA, EL2 | ||
593 | * Currently handles both VAE2 and VALE2, since we don't support | ||
594 | * flush-last-level-only. | ||
595 | */ | ||
596 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
597 | static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
598 | uint64_t value) | ||
599 | { | ||
600 | - /* Invalidate by VA, EL3 | ||
601 | + /* | ||
602 | + * Invalidate by VA, EL3 | ||
603 | * Currently handles both VAE3 and VALE3, since we don't support | ||
604 | * flush-last-level-only. | ||
605 | */ | ||
606 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
607 | static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
608 | uint64_t value) | ||
609 | { | ||
610 | - /* Invalidate by VA, EL1&0 (AArch64 version). | ||
611 | + /* | ||
612 | + * Invalidate by VA, EL1&0 (AArch64 version). | ||
613 | * Currently handles all of VAE1, VAAE1, VAALE1 and VALE1, | ||
614 | * since we don't support flush-for-specific-ASID-only or | ||
615 | * flush-last-level-only. | ||
616 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult sp_el0_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
617 | bool isread) | ||
618 | { | ||
619 | if (!(env->pstate & PSTATE_SP)) { | ||
620 | - /* Access to SP_EL0 is undefined if it's being used as | ||
621 | + /* | ||
622 | + * Access to SP_EL0 is undefined if it's being used as | ||
623 | * the stack pointer. | ||
624 | */ | ||
625 | return CP_ACCESS_TRAP_UNCATEGORIZED; | ||
626 | @@ -XXX,XX +XXX,XX @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
627 | } | ||
628 | |||
629 | if (raw_read(env, ri) == value) { | ||
630 | - /* Skip the TLB flush if nothing actually changed; Linux likes | ||
631 | + /* | ||
632 | + * Skip the TLB flush if nothing actually changed; Linux likes | ||
633 | * to do a lot of pointless SCTLR writes. | ||
634 | */ | ||
635 | return; | ||
636 | @@ -XXX,XX +XXX,XX @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
637 | } | ||
638 | |||
639 | static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
640 | - /* Minimal set of EL0-visible registers. This will need to be expanded | ||
641 | + /* | ||
642 | + * Minimal set of EL0-visible registers. This will need to be expanded | ||
643 | * significantly for system emulation of AArch64 CPUs. | ||
644 | */ | ||
645 | { .name = "NZCV", .state = ARM_CP_STATE_AA64, | ||
646 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
647 | .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0, | ||
648 | .access = PL1_RW, | ||
649 | .fieldoffset = offsetof(CPUARMState, banked_spsr[BANK_SVC]) }, | ||
650 | - /* We rely on the access checks not allowing the guest to write to the | ||
651 | + /* | ||
652 | + * We rely on the access checks not allowing the guest to write to the | ||
653 | * state field when SPSel indicates that it's being used as the stack | ||
654 | * pointer. | ||
655 | */ | ||
656 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
657 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
658 | valid_mask &= ~HCR_HCD; | ||
659 | } else if (cpu->psci_conduit != QEMU_PSCI_CONDUIT_SMC) { | ||
660 | - /* Architecturally HCR.TSC is RES0 if EL3 is not implemented. | ||
661 | + /* | ||
662 | + * Architecturally HCR.TSC is RES0 if EL3 is not implemented. | ||
663 | * However, if we're using the SMC PSCI conduit then QEMU is | ||
664 | * effectively acting like EL3 firmware and so the guest at | ||
665 | * EL2 should retain the ability to prevent EL1 from being | ||
666 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
667 | .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
668 | .writefn = tlbi_aa64_vae2is_write }, | ||
669 | #ifndef CONFIG_USER_ONLY | ||
670 | - /* Unlike the other EL2-related AT operations, these must | ||
671 | + /* | ||
672 | + * Unlike the other EL2-related AT operations, these must | ||
673 | * UNDEF from EL3 if EL2 is not implemented, which is why we | ||
674 | * define them here rather than with the rest of the AT ops. | ||
675 | */ | ||
676 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
677 | .access = PL2_W, .accessfn = at_s1e2_access, | ||
678 | .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, | ||
679 | .writefn = ats_write64 }, | ||
680 | - /* The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE | ||
681 | + /* | ||
682 | + * The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE | ||
683 | * if EL2 is not implemented; we choose to UNDEF. Behaviour at EL3 | ||
684 | * with SCR.NS == 0 outside Monitor mode is UNPREDICTABLE; we choose | ||
685 | * to behave as if SCR.NS was 1. | ||
686 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
687 | .writefn = ats1h_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC }, | ||
688 | { .name = "CNTHCTL_EL2", .state = ARM_CP_STATE_BOTH, | ||
689 | .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 1, .opc2 = 0, | ||
690 | - /* ARMv7 requires bit 0 and 1 to reset to 1. ARMv8 defines the | ||
691 | + /* | ||
692 | + * ARMv7 requires bit 0 and 1 to reset to 1. ARMv8 defines the | ||
693 | * reset values as IMPDEF. We choose to reset to 3 to comply with | ||
694 | * both ARMv7 and ARMv8. | ||
695 | */ | ||
696 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = { | ||
697 | static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
698 | bool isread) | ||
699 | { | ||
700 | - /* The NSACR is RW at EL3, and RO for NS EL1 and NS EL2. | ||
701 | + /* | ||
702 | + * The NSACR is RW at EL3, and RO for NS EL1 and NS EL2. | ||
703 | * At Secure EL1 it traps to EL3 or EL2. | ||
704 | */ | ||
705 | if (arm_current_el(env) == 3) { | ||
706 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
707 | } | ||
708 | } | ||
709 | |||
710 | -/* We don't know until after realize whether there's a GICv3 | ||
711 | +/* | ||
712 | + * We don't know until after realize whether there's a GICv3 | ||
713 | * attached, and that is what registers the gicv3 sysregs. | ||
714 | * So we have to fill in the GIC fields in ID_PFR/ID_PFR1_EL1/ID_AA64PFR0_EL1 | ||
715 | * at runtime. | ||
716 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
717 | } | ||
718 | #endif | ||
719 | |||
720 | -/* Shared logic between LORID and the rest of the LOR* registers. | ||
721 | +/* | ||
722 | + * Shared logic between LORID and the rest of the LOR* registers. | ||
723 | * Secure state exclusion has already been dealt with. | ||
724 | */ | ||
725 | static CPAccessResult access_lor_ns(CPUARMState *env, | ||
726 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
727 | |||
728 | define_arm_cp_regs(cpu, cp_reginfo); | ||
729 | if (!arm_feature(env, ARM_FEATURE_V8)) { | ||
730 | - /* Must go early as it is full of wildcards that may be | ||
731 | + /* | ||
732 | + * Must go early as it is full of wildcards that may be | ||
733 | * overridden by later definitions. | ||
734 | */ | ||
735 | define_arm_cp_regs(cpu, not_v8_cp_reginfo); | ||
736 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
737 | .access = PL1_R, .type = ARM_CP_CONST, | ||
738 | .accessfn = access_aa32_tid3, | ||
739 | .resetvalue = cpu->isar.id_pfr0 }, | ||
740 | - /* ID_PFR1 is not a plain ARM_CP_CONST because we don't know | ||
741 | + /* | ||
742 | + * ID_PFR1 is not a plain ARM_CP_CONST because we don't know | ||
743 | * the value of the GIC field until after we define these regs. | ||
744 | */ | ||
745 | { .name = "ID_PFR1", .state = ARM_CP_STATE_BOTH, | ||
746 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
747 | |||
748 | define_arm_cp_regs(cpu, el3_regs); | ||
749 | } | ||
750 | - /* The behaviour of NSACR is sufficiently various that we don't | ||
751 | + /* | ||
752 | + * The behaviour of NSACR is sufficiently various that we don't | ||
753 | * try to describe it in a single reginfo: | ||
754 | * if EL3 is 64 bit, then trap to EL3 from S EL1, | ||
755 | * reads as constant 0xc00 from NS EL1 and NS EL2 | ||
756 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
757 | if (cpu_isar_feature(aa32_jazelle, cpu)) { | ||
758 | define_arm_cp_regs(cpu, jazelle_regs); | ||
759 | } | ||
760 | - /* Slightly awkwardly, the OMAP and StrongARM cores need all of | ||
761 | + /* | ||
762 | + * Slightly awkwardly, the OMAP and StrongARM cores need all of | ||
763 | * cp15 crn=0 to be writes-ignored, whereas for other cores they should | ||
764 | * be read-only (ie write causes UNDEF exception). | ||
765 | */ | ||
766 | { | ||
767 | ARMCPRegInfo id_pre_v8_midr_cp_reginfo[] = { | ||
768 | - /* Pre-v8 MIDR space. | ||
769 | + /* | ||
770 | + * Pre-v8 MIDR space. | ||
771 | * Note that the MIDR isn't a simple constant register because | ||
772 | * of the TI925 behaviour where writes to another register can | ||
773 | * cause the MIDR value to change. | ||
774 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
775 | if (arm_feature(env, ARM_FEATURE_OMAPCP) || | ||
776 | arm_feature(env, ARM_FEATURE_STRONGARM)) { | ||
777 | size_t i; | ||
778 | - /* Register the blanket "writes ignored" value first to cover the | ||
779 | + /* | ||
780 | + * Register the blanket "writes ignored" value first to cover the | ||
781 | * whole space. Then update the specific ID registers to allow write | ||
782 | * access, so that they ignore writes rather than causing them to | ||
783 | * UNDEF. | ||
784 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
785 | .raw_writefn = raw_write, | ||
786 | }; | ||
787 | if (arm_feature(env, ARM_FEATURE_XSCALE)) { | ||
788 | - /* Normally we would always end the TB on an SCTLR write, but Linux | ||
789 | + /* | ||
790 | + * Normally we would always end the TB on an SCTLR write, but Linux | ||
791 | * arch/arm/mach-pxa/sleep.S expects two instructions following | ||
792 | * an MMU enable to execute from cache. Imitate this behaviour. | ||
793 | */ | ||
794 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
795 | void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
796 | const ARMCPRegInfo *r, void *opaque) | ||
797 | { | ||
798 | - /* Define implementations of coprocessor registers. | ||
799 | + /* | ||
800 | + * Define implementations of coprocessor registers. | ||
801 | * We store these in a hashtable because typically | ||
802 | * there are less than 150 registers in a space which | ||
803 | * is 16*16*16*8*8 = 262144 in size. | ||
804 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
805 | default: | ||
806 | g_assert_not_reached(); | ||
807 | } | ||
808 | - /* The AArch64 pseudocode CheckSystemAccess() specifies that op1 | ||
809 | + /* | ||
810 | + * The AArch64 pseudocode CheckSystemAccess() specifies that op1 | ||
811 | * encodes a minimum access level for the register. We roll this | ||
812 | * runtime check into our general permission check code, so check | ||
813 | * here that the reginfo's specified permissions are strict enough | ||
814 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
815 | assert((r->access & ~mask) == 0); | ||
816 | } | ||
817 | |||
818 | - /* Check that the register definition has enough info to handle | ||
819 | + /* | ||
820 | + * Check that the register definition has enough info to handle | ||
821 | * reads and writes if they are permitted. | ||
822 | */ | ||
823 | if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) { | ||
824 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
825 | continue; | ||
826 | } | ||
827 | if (state == ARM_CP_STATE_AA32) { | ||
828 | - /* Under AArch32 CP registers can be common | ||
829 | + /* | ||
830 | + * Under AArch32 CP registers can be common | ||
831 | * (same for secure and non-secure world) or banked. | ||
832 | */ | ||
833 | char *name; | ||
834 | @@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, | ||
835 | g_assert_not_reached(); | ||
836 | } | ||
837 | } else { | ||
838 | - /* AArch64 registers get mapped to non-secure instance | ||
839 | - * of AArch32 */ | ||
840 | + /* | ||
841 | + * AArch64 registers get mapped to non-secure instance | ||
842 | + * of AArch32 | ||
843 | + */ | ||
844 | add_cpreg_to_hashtable(cpu, r, opaque, state, | ||
845 | ARM_CP_SECSTATE_NS, | ||
846 | crm, opc1, opc2, r->name); | ||
847 | @@ -XXX,XX +XXX,XX @@ void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque) | ||
848 | |||
849 | static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type) | ||
850 | { | ||
851 | - /* Return true if it is not valid for us to switch to | ||
852 | + /* | ||
853 | + * Return true if it is not valid for us to switch to | ||
854 | * this CPU mode (ie all the UNPREDICTABLE cases in | ||
855 | * the ARM ARM CPSRWriteByInstr pseudocode). | ||
856 | */ | ||
857 | @@ -XXX,XX +XXX,XX @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type) | ||
858 | case ARM_CPU_MODE_UND: | ||
859 | case ARM_CPU_MODE_IRQ: | ||
860 | case ARM_CPU_MODE_FIQ: | ||
861 | - /* Note that we don't implement the IMPDEF NSACR.RFR which in v7 | ||
862 | + /* | ||
863 | + * Note that we don't implement the IMPDEF NSACR.RFR which in v7 | ||
864 | * allows FIQ mode to be Secure-only. (In v8 this doesn't exist.) | ||
865 | */ | ||
866 | - /* If HCR.TGE is set then changes from Monitor to NS PL1 via MSR | ||
867 | + /* | ||
868 | + * If HCR.TGE is set then changes from Monitor to NS PL1 via MSR | ||
869 | * and CPS are treated as illegal mode changes. | ||
870 | */ | ||
871 | if (write_type == CPSRWriteByInstr && | ||
872 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
873 | env->GE = (val >> 16) & 0xf; | ||
874 | } | ||
875 | |||
876 | - /* In a V7 implementation that includes the security extensions but does | ||
877 | + /* | ||
878 | + * In a V7 implementation that includes the security extensions but does | ||
879 | * not include Virtualization Extensions the SCR.FW and SCR.AW bits control | ||
880 | * whether non-secure software is allowed to change the CPSR_F and CPSR_A | ||
881 | * bits respectively. | ||
882 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
883 | changed_daif = (env->daif ^ val) & mask; | ||
884 | |||
885 | if (changed_daif & CPSR_A) { | ||
886 | - /* Check to see if we are allowed to change the masking of async | ||
887 | + /* | ||
888 | + * Check to see if we are allowed to change the masking of async | ||
889 | * abort exceptions from a non-secure state. | ||
890 | */ | ||
891 | if (!(env->cp15.scr_el3 & SCR_AW)) { | ||
892 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
893 | } | ||
894 | |||
895 | if (changed_daif & CPSR_F) { | ||
896 | - /* Check to see if we are allowed to change the masking of FIQ | ||
897 | + /* | ||
898 | + * Check to see if we are allowed to change the masking of FIQ | ||
899 | * exceptions from a non-secure state. | ||
900 | */ | ||
901 | if (!(env->cp15.scr_el3 & SCR_FW)) { | ||
902 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
903 | mask &= ~CPSR_F; | ||
904 | } | ||
905 | |||
906 | - /* Check whether non-maskable FIQ (NMFI) support is enabled. | ||
907 | + /* | ||
908 | + * Check whether non-maskable FIQ (NMFI) support is enabled. | ||
909 | * If this bit is set software is not allowed to mask | ||
910 | * FIQs, but is allowed to set CPSR_F to 0. | ||
911 | */ | ||
912 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
913 | if (write_type != CPSRWriteRaw && | ||
914 | ((env->uncached_cpsr ^ val) & mask & CPSR_M)) { | ||
915 | if ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_USR) { | ||
916 | - /* Note that we can only get here in USR mode if this is a | ||
917 | + /* | ||
918 | + * Note that we can only get here in USR mode if this is a | ||
919 | * gdb stub write; for this case we follow the architectural | ||
920 | * behaviour for guest writes in USR mode of ignoring an attempt | ||
921 | * to switch mode. (Those are caught by translate.c for writes | ||
922 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, | ||
923 | */ | ||
924 | mask &= ~CPSR_M; | ||
925 | } else if (bad_mode_switch(env, val & CPSR_M, write_type)) { | ||
926 | - /* Attempt to switch to an invalid mode: this is UNPREDICTABLE in | ||
927 | + /* | ||
928 | + * Attempt to switch to an invalid mode: this is UNPREDICTABLE in | ||
929 | * v7, and has defined behaviour in v8: | ||
930 | * + leave CPSR.M untouched | ||
931 | * + allow changes to the other CPSR fields | ||
932 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) | ||
933 | env->regs[14] = env->banked_r14[r14_bank_number(mode)]; | ||
934 | } | ||
935 | |||
936 | -/* Physical Interrupt Target EL Lookup Table | ||
937 | +/* | ||
938 | + * Physical Interrupt Target EL Lookup Table | ||
939 | * | ||
940 | * [ From ARM ARM section G1.13.4 (Table G1-15) ] | ||
941 | * | ||
942 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
943 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
944 | rw = ((env->cp15.scr_el3 & SCR_RW) == SCR_RW); | ||
945 | } else { | ||
946 | - /* Either EL2 is the highest EL (and so the EL2 register width | ||
947 | + /* | ||
948 | + * Either EL2 is the highest EL (and so the EL2 register width | ||
949 | * is given by is64); or there is no EL2 or EL3, in which case | ||
950 | * the value of 'rw' does not affect the table lookup anyway. | ||
951 | */ | ||
952 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
953 | env->banked_r13[bank_number(ARM_CPU_MODE_UND)] = env->xregs[23]; | ||
954 | } | ||
955 | |||
956 | - /* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ | ||
957 | + /* | ||
958 | + * Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ | ||
959 | * mode, then we can copy to r8-r14. Otherwise, we copy to the | ||
960 | * FIQ bank for r8-r14. | ||
961 | */ | ||
962 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) | ||
963 | /* High vectors. When enabled, base address cannot be remapped. */ | ||
964 | addr += 0xffff0000; | ||
965 | } else { | ||
966 | - /* ARM v7 architectures provide a vector base address register to remap | ||
967 | + /* | ||
968 | + * ARM v7 architectures provide a vector base address register to remap | ||
969 | * the interrupt vector table. | ||
970 | * This register is only followed in non-monitor mode, and is banked. | ||
971 | * Note: only bits 31:5 are valid. | ||
972 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
973 | aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); | ||
974 | |||
975 | if (cur_el < new_el) { | ||
976 | - /* Entry vector offset depends on whether the implemented EL | ||
977 | + /* | ||
978 | + * Entry vector offset depends on whether the implemented EL | ||
979 | * immediately lower than the target level is using AArch32 or AArch64 | ||
980 | */ | ||
981 | bool is_aa64; | ||
982 | @@ -XXX,XX +XXX,XX @@ static void handle_semihosting(CPUState *cs) | ||
983 | } | ||
984 | #endif | ||
985 | |||
986 | -/* Handle a CPU exception for A and R profile CPUs. | ||
987 | +/* | ||
988 | + * Handle a CPU exception for A and R profile CPUs. | ||
989 | * Do any appropriate logging, handle PSCI calls, and then hand off | ||
990 | * to the AArch64-entry or AArch32-entry function depending on the | ||
991 | * target exception level's register width. | ||
992 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) | ||
993 | } | ||
994 | #endif | ||
995 | |||
996 | - /* Hooks may change global state so BQL should be held, also the | ||
997 | + /* | ||
998 | + * Hooks may change global state so BQL should be held, also the | ||
999 | * BQL needs to be held for any modification of | ||
1000 | * cs->interrupt_request. | ||
1001 | */ | ||
1002 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
1003 | }; | ||
1004 | } | ||
1005 | |||
1006 | -/* Note that signed overflow is undefined in C. The following routines are | ||
1007 | - careful to use unsigned types where modulo arithmetic is required. | ||
1008 | - Failure to do so _will_ break on newer gcc. */ | ||
1009 | +/* | ||
1010 | + * Note that signed overflow is undefined in C. The following routines are | ||
1011 | + * careful to use unsigned types where modulo arithmetic is required. | ||
1012 | + * Failure to do so _will_ break on newer gcc. | ||
1013 | + */ | ||
1014 | |||
1015 | /* Signed saturating arithmetic. */ | ||
1016 | |||
1017 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b) | ||
1018 | return (a & mask) | (b & ~mask); | ||
1019 | } | ||
1020 | |||
1021 | -/* CRC helpers. | ||
1022 | +/* | ||
1023 | + * CRC helpers. | ||
1024 | * The upper bytes of val (above the number specified by 'bytes') must have | ||
1025 | * been zeroed out by the caller. | ||
1026 | */ | ||
1027 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes) | ||
1028 | return crc32c(acc, buf, bytes) ^ 0xffffffff; | ||
1029 | } | ||
1030 | |||
1031 | -/* Return the exception level to which FP-disabled exceptions should | ||
1032 | +/* | ||
1033 | + * Return the exception level to which FP-disabled exceptions should | ||
1034 | * be taken, or 0 if FP is enabled. | ||
1035 | */ | ||
1036 | int fp_exception_el(CPUARMState *env, int cur_el) | ||
1037 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
1038 | #ifndef CONFIG_USER_ONLY | ||
1039 | uint64_t hcr_el2; | ||
1040 | |||
1041 | - /* CPACR and the CPTR registers don't exist before v6, so FP is | ||
1042 | + /* | ||
1043 | + * CPACR and the CPTR registers don't exist before v6, so FP is | ||
1044 | * always accessible | ||
1045 | */ | ||
1046 | if (!arm_feature(env, ARM_FEATURE_V6)) { | ||
1047 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
1048 | |||
1049 | hcr_el2 = arm_hcr_el2_eff(env); | ||
1050 | |||
1051 | - /* The CPACR controls traps to EL1, or PL1 if we're 32 bit: | ||
1052 | + /* | ||
1053 | + * The CPACR controls traps to EL1, or PL1 if we're 32 bit: | ||
1054 | * 0, 2 : trap EL0 and EL1/PL1 accesses | ||
1055 | * 1 : trap only EL0 accesses | ||
1056 | * 3 : trap no accesses | ||
87 | -- | 1057 | -- |
88 | 2.20.1 | 1058 | 2.25.1 |
89 | |||
90 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | If the whole SID range (32b) is invalidated (SMMU_CMD_CFGI_ALL), | 3 | Fix the following: |
4 | @end overflows and we fail to handle the command properly. | ||
5 | 4 | ||
6 | Once this gets fixed, the current code really is awkward in the | 5 | ERROR: spaces required around that '|' (ctx:VxV) |
7 | sense it loops over the whole range instead of removing the | 6 | ERROR: space required before the open parenthesis '(' |
8 | currently cached configs through a hash table lookup. | 7 | ERROR: spaces required around that '+' (ctx:VxB) |
8 | ERROR: space prohibited between function name and open parenthesis '(' | ||
9 | 9 | ||
10 | Fix both the overflow and the lookup. | 10 | (the last two still have some occurrences in macros which I left |
11 | behind because it might impact readability) | ||
11 | 12 | ||
12 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 13 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
14 | Message-id: 20210309102742.30442-7-eric.auger@redhat.com | 15 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
16 | Message-id: 20221213190537.511-3-farosas@suse.de | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 18 | --- |
17 | hw/arm/smmu-internal.h | 5 +++++ | 19 | target/arm/helper.c | 42 +++++++++++++++++++++--------------------- |
18 | hw/arm/smmuv3.c | 34 ++++++++++++++++++++-------------- | 20 | 1 file changed, 21 insertions(+), 21 deletions(-) |
19 | 2 files changed, 25 insertions(+), 14 deletions(-) | ||
20 | 21 | ||
21 | diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
22 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/arm/smmu-internal.h | 24 | --- a/target/arm/helper.c |
24 | +++ b/hw/arm/smmu-internal.h | 25 | +++ b/target/arm/helper.c |
25 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUIOTLBPageInvInfo { | 26 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque) |
26 | uint64_t mask; | 27 | uint32_t regidx = (uintptr_t)key; |
27 | } SMMUIOTLBPageInvInfo; | 28 | const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); |
28 | 29 | ||
29 | +typedef struct SMMUSIDRange { | 30 | - if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { |
30 | + uint32_t start; | 31 | + if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) { |
31 | + uint32_t end; | 32 | cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx); |
32 | +} SMMUSIDRange; | 33 | /* The value array need not be initialized at this point */ |
33 | + | 34 | cpu->cpreg_array_len++; |
34 | #endif | 35 | @@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque) |
35 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 36 | |
36 | index XXXXXXX..XXXXXXX 100644 | 37 | ri = g_hash_table_lookup(cpu->cp_regs, key); |
37 | --- a/hw/arm/smmuv3.c | 38 | |
38 | +++ b/hw/arm/smmuv3.c | 39 | - if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { |
39 | @@ -XXX,XX +XXX,XX @@ | 40 | + if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) { |
40 | 41 | cpu->cpreg_array_len++; | |
41 | #include "hw/arm/smmuv3.h" | ||
42 | #include "smmuv3-internal.h" | ||
43 | +#include "smmu-internal.h" | ||
44 | |||
45 | /** | ||
46 | * smmuv3_trigger_irq - pulse @irq if enabled and update | ||
47 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
48 | } | 42 | } |
49 | } | 43 | } |
50 | 44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | |
51 | +static gboolean | 45 | .resetfn = arm_cp_reset_ignore }, |
52 | +smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data) | 46 | { .name = "TPIDRRO_EL0", .state = ARM_CP_STATE_AA64, |
53 | +{ | 47 | .opc0 = 3, .opc1 = 3, .opc2 = 3, .crn = 13, .crm = 0, |
54 | + SMMUDevice *sdev = (SMMUDevice *)key; | 48 | - .access = PL0_R|PL1_W, |
55 | + uint32_t sid = smmu_get_sid(sdev); | 49 | + .access = PL0_R | PL1_W, |
56 | + SMMUSIDRange *sid_range = (SMMUSIDRange *)user_data; | 50 | .fieldoffset = offsetof(CPUARMState, cp15.tpidrro_el[0]), |
57 | + | 51 | .resetvalue = 0}, |
58 | + if (sid < sid_range->start || sid > sid_range->end) { | 52 | { .name = "TPIDRURO", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 3, |
59 | + return false; | 53 | - .access = PL0_R|PL1_W, |
60 | + } | 54 | + .access = PL0_R | PL1_W, |
61 | + trace_smmuv3_config_cache_inv(sid); | 55 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidruro_s), |
62 | + return true; | 56 | offsetoflow32(CPUARMState, cp15.tpidruro_ns) }, |
63 | +} | 57 | .resetfn = arm_cp_reset_ignore }, |
64 | + | 58 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { |
65 | static int smmuv3_cmdq_consume(SMMUv3State *s) | 59 | .resetvalue = 0 }, |
66 | { | 60 | /* The cache ops themselves: these all NOP for QEMU */ |
67 | SMMUState *bs = ARM_SMMU(s); | 61 | { .name = "IICR", .cp = 15, .crm = 5, .opc1 = 0, |
68 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | 62 | - .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, |
69 | } | 63 | + .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, |
70 | case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */ | 64 | { .name = "IDCR", .cp = 15, .crm = 6, .opc1 = 0, |
71 | { | 65 | - .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, |
72 | - uint32_t start = CMD_SID(&cmd), end, i; | 66 | + .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, |
73 | + uint32_t start = CMD_SID(&cmd); | 67 | { .name = "CDCR", .cp = 15, .crm = 12, .opc1 = 0, |
74 | uint8_t range = CMD_STE_RANGE(&cmd); | 68 | - .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, |
75 | + uint64_t end = start + (1ULL << (range + 1)) - 1; | 69 | + .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, |
76 | + SMMUSIDRange sid_range = {start, end}; | 70 | { .name = "PIR", .cp = 15, .crm = 12, .opc1 = 1, |
77 | 71 | - .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | |
78 | if (CMD_SSEC(&cmd)) { | 72 | + .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, |
79 | cmd_error = SMMU_CERROR_ILL; | 73 | { .name = "PDR", .cp = 15, .crm = 12, .opc1 = 2, |
80 | break; | 74 | - .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, |
81 | } | 75 | + .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, |
82 | - | 76 | { .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0, |
83 | - end = start + (1 << (range + 1)) - 1; | 77 | - .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, |
84 | trace_smmuv3_cmdq_cfgi_ste_range(start, end); | 78 | + .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, |
85 | - | 79 | }; |
86 | - for (i = start; i <= end; i++) { | 80 | |
87 | - IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, i); | 81 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { |
88 | - SMMUDevice *sdev; | 82 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
89 | - | 83 | ARMCPRegInfo cbar = { |
90 | - if (!mr) { | 84 | .name = "CBAR", |
91 | - continue; | 85 | .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0, |
92 | - } | 86 | - .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar, |
93 | - sdev = container_of(mr, SMMUDevice, iommu); | 87 | + .access = PL1_R | PL3_W, .resetvalue = cpu->reset_cbar, |
94 | - smmuv3_flush_config(sdev); | 88 | .fieldoffset = offsetof(CPUARMState, |
95 | - } | 89 | cp15.c15_config_base_address) |
96 | + g_hash_table_foreach_remove(bs->configs, smmuv3_invalidate_ste, | 90 | }; |
97 | + &sid_range); | 91 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) |
98 | break; | 92 | return; |
99 | } | 93 | |
100 | case SMMU_CMD_CFGI_CD: | 94 | if (old_mode == ARM_CPU_MODE_FIQ) { |
95 | - memcpy (env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t)); | ||
96 | - memcpy (env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t)); | ||
97 | + memcpy(env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t)); | ||
98 | + memcpy(env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t)); | ||
99 | } else if (mode == ARM_CPU_MODE_FIQ) { | ||
100 | - memcpy (env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t)); | ||
101 | - memcpy (env->regs + 8, env->fiq_regs, 5 * sizeof(uint32_t)); | ||
102 | + memcpy(env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t)); | ||
103 | + memcpy(env->regs + 8, env->fiq_regs, 5 * sizeof(uint32_t)); | ||
104 | } | ||
105 | |||
106 | i = bank_number(old_mode); | ||
107 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) | ||
108 | RESULT(sum, n, 16); \ | ||
109 | if (sum >= 0) \ | ||
110 | ge |= 3 << (n * 2); \ | ||
111 | - } while(0) | ||
112 | + } while (0) | ||
113 | |||
114 | #define SARITH8(a, b, n, op) do { \ | ||
115 | int32_t sum; \ | ||
116 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) | ||
117 | RESULT(sum, n, 8); \ | ||
118 | if (sum >= 0) \ | ||
119 | ge |= 1 << n; \ | ||
120 | - } while(0) | ||
121 | + } while (0) | ||
122 | |||
123 | |||
124 | #define ADD16(a, b, n) SARITH16(a, b, n, +) | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) | ||
126 | RESULT(sum, n, 16); \ | ||
127 | if ((sum >> 16) == 1) \ | ||
128 | ge |= 3 << (n * 2); \ | ||
129 | - } while(0) | ||
130 | + } while (0) | ||
131 | |||
132 | #define ADD8(a, b, n) do { \ | ||
133 | uint32_t sum; \ | ||
134 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) | ||
135 | RESULT(sum, n, 8); \ | ||
136 | if ((sum >> 8) == 1) \ | ||
137 | ge |= 1 << n; \ | ||
138 | - } while(0) | ||
139 | + } while (0) | ||
140 | |||
141 | #define SUB16(a, b, n) do { \ | ||
142 | uint32_t sum; \ | ||
143 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) | ||
144 | RESULT(sum, n, 16); \ | ||
145 | if ((sum >> 16) == 0) \ | ||
146 | ge |= 3 << (n * 2); \ | ||
147 | - } while(0) | ||
148 | + } while (0) | ||
149 | |||
150 | #define SUB8(a, b, n) do { \ | ||
151 | uint32_t sum; \ | ||
152 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) | ||
153 | RESULT(sum, n, 8); \ | ||
154 | if ((sum >> 8) == 0) \ | ||
155 | ge |= 1 << n; \ | ||
156 | - } while(0) | ||
157 | + } while (0) | ||
158 | |||
159 | #define PFX u | ||
160 | #define ARITH_GE | ||
101 | -- | 161 | -- |
102 | 2.20.1 | 162 | 2.25.1 |
103 | |||
104 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds fan_splitters (split IRQs) in NPCM7XX boards. Each fan | 3 | Fix this: |
4 | splitter corresponds to 1 PWM output and can connect to multiple fan | 4 | ERROR: braces {} are necessary for all arms of this statement |
5 | inputs (MFT devices). | ||
6 | In NPCM7XX boards(NPCM750 EVB and Quanta GSJ boards), we initializes | ||
7 | these splitters and connect them to their corresponding modules | ||
8 | according their specific device trees. | ||
9 | 5 | ||
10 | Reviewed-by: Doug Evans <dje@google.com> | 6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
11 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | 7 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
12 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | 8 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20221213190537.511-4-farosas@suse.de |
14 | Message-id: 20210311180855.149764-5-wuhaotsh@google.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 11 | --- |
17 | include/hw/arm/npcm7xx.h | 11 ++++- | 12 | target/arm/helper.c | 67 ++++++++++++++++++++++++++++----------------- |
18 | hw/arm/npcm7xx_boards.c | 99 ++++++++++++++++++++++++++++++++++++++++ | 13 | 1 file changed, 42 insertions(+), 25 deletions(-) |
19 | 2 files changed, 109 insertions(+), 1 deletion(-) | ||
20 | 14 | ||
21 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/npcm7xx.h | 17 | --- a/target/arm/helper.c |
24 | +++ b/include/hw/arm/npcm7xx.h | 18 | +++ b/target/arm/helper.c |
25 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, |
26 | 20 | env->CF = (val >> 29) & 1; | |
27 | #include "hw/boards.h" | 21 | env->VF = (val << 3) & 0x80000000; |
28 | #include "hw/adc/npcm7xx_adc.h" | 22 | } |
29 | +#include "hw/core/split-irq.h" | 23 | - if (mask & CPSR_Q) |
30 | #include "hw/cpu/a9mpcore.h" | 24 | + if (mask & CPSR_Q) { |
31 | #include "hw/gpio/npcm7xx_gpio.h" | 25 | env->QF = ((val & CPSR_Q) != 0); |
32 | #include "hw/i2c/npcm7xx_smbus.h" | 26 | - if (mask & CPSR_T) |
33 | @@ -XXX,XX +XXX,XX @@ | 27 | + } |
34 | #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */ | 28 | + if (mask & CPSR_T) { |
35 | #define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */ | 29 | env->thumb = ((val & CPSR_T) != 0); |
36 | 30 | + } | |
37 | +#define NPCM7XX_NR_PWM_MODULES 2 | 31 | if (mask & CPSR_IT_0_1) { |
38 | + | 32 | env->condexec_bits &= ~3; |
39 | typedef struct NPCM7xxMachine { | 33 | env->condexec_bits |= (val >> 25) & 3; |
40 | MachineState parent; | 34 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) |
41 | + /* | 35 | int i; |
42 | + * PWM fan splitter. each splitter connects to one PWM output and | 36 | |
43 | + * multiple MFT inputs. | 37 | old_mode = env->uncached_cpsr & CPSR_M; |
44 | + */ | 38 | - if (mode == old_mode) |
45 | + SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES * | 39 | + if (mode == old_mode) { |
46 | + NPCM7XX_PWM_PER_MODULE]; | 40 | return; |
47 | } NPCM7xxMachine; | 41 | + } |
48 | 42 | ||
49 | #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx") | 43 | if (old_mode == ARM_CPU_MODE_FIQ) { |
50 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState { | 44 | memcpy(env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t)); |
51 | NPCM7xxCLKState clk; | 45 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) |
52 | NPCM7xxTimerCtrlState tim[3]; | 46 | new_mode = ARM_CPU_MODE_UND; |
53 | NPCM7xxADCState adc; | 47 | addr = 0x04; |
54 | - NPCM7xxPWMState pwm[2]; | 48 | mask = CPSR_I; |
55 | + NPCM7xxPWMState pwm[NPCM7XX_NR_PWM_MODULES]; | 49 | - if (env->thumb) |
56 | NPCM7xxMFTState mft[8]; | 50 | + if (env->thumb) { |
57 | NPCM7xxOTPState key_storage; | 51 | offset = 2; |
58 | NPCM7xxOTPState fuse_array; | 52 | - else |
59 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | 53 | + } else { |
60 | index XXXXXXX..XXXXXXX 100644 | 54 | offset = 4; |
61 | --- a/hw/arm/npcm7xx_boards.c | 55 | + } |
62 | +++ b/hw/arm/npcm7xx_boards.c | 56 | break; |
63 | @@ -XXX,XX +XXX,XX @@ | 57 | case EXCP_SWI: |
64 | #include "hw/core/cpu.h" | 58 | new_mode = ARM_CPU_MODE_SVC; |
65 | #include "hw/i2c/smbus_eeprom.h" | 59 | @@ -XXX,XX +XXX,XX @@ static inline uint16_t add16_sat(uint16_t a, uint16_t b) |
66 | #include "hw/loader.h" | 60 | |
67 | +#include "hw/qdev-core.h" | 61 | res = a + b; |
68 | #include "hw/qdev-properties.h" | 62 | if (((res ^ a) & 0x8000) && !((a ^ b) & 0x8000)) { |
69 | #include "qapi/error.h" | 63 | - if (a & 0x8000) |
70 | #include "qemu-common.h" | 64 | + if (a & 0x8000) { |
71 | @@ -XXX,XX +XXX,XX @@ static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr, | 65 | res = 0x8000; |
72 | i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort); | 66 | - else |
67 | + } else { | ||
68 | res = 0x7fff; | ||
69 | + } | ||
70 | } | ||
71 | return res; | ||
73 | } | 72 | } |
74 | 73 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t add8_sat(uint8_t a, uint8_t b) | |
75 | +static void npcm7xx_init_pwm_splitter(NPCM7xxMachine *machine, | 74 | |
76 | + NPCM7xxState *soc, const int *fan_counts) | 75 | res = a + b; |
77 | +{ | 76 | if (((res ^ a) & 0x80) && !((a ^ b) & 0x80)) { |
78 | + SplitIRQ *splitters = machine->fan_splitter; | 77 | - if (a & 0x80) |
79 | + | 78 | + if (a & 0x80) { |
80 | + /* | 79 | res = 0x80; |
81 | + * PWM 0~3 belong to module 0 output 0~3. | 80 | - else |
82 | + * PWM 4~7 belong to module 1 output 0~3. | 81 | + } else { |
83 | + */ | 82 | res = 0x7f; |
84 | + for (int i = 0; i < NPCM7XX_NR_PWM_MODULES; ++i) { | ||
85 | + for (int j = 0; j < NPCM7XX_PWM_PER_MODULE; ++j) { | ||
86 | + int splitter_no = i * NPCM7XX_PWM_PER_MODULE + j; | ||
87 | + DeviceState *splitter; | ||
88 | + | ||
89 | + if (fan_counts[splitter_no] < 1) { | ||
90 | + continue; | ||
91 | + } | ||
92 | + object_initialize_child(OBJECT(machine), "fan-splitter[*]", | ||
93 | + &splitters[splitter_no], TYPE_SPLIT_IRQ); | ||
94 | + splitter = DEVICE(&splitters[splitter_no]); | ||
95 | + qdev_prop_set_uint16(splitter, "num-lines", | ||
96 | + fan_counts[splitter_no]); | ||
97 | + qdev_realize(splitter, NULL, &error_abort); | ||
98 | + qdev_connect_gpio_out_named(DEVICE(&soc->pwm[i]), "duty-gpio-out", | ||
99 | + j, qdev_get_gpio_in(splitter, 0)); | ||
100 | + } | 83 | + } |
84 | } | ||
85 | return res; | ||
86 | } | ||
87 | @@ -XXX,XX +XXX,XX @@ static inline uint16_t sub16_sat(uint16_t a, uint16_t b) | ||
88 | |||
89 | res = a - b; | ||
90 | if (((res ^ a) & 0x8000) && ((a ^ b) & 0x8000)) { | ||
91 | - if (a & 0x8000) | ||
92 | + if (a & 0x8000) { | ||
93 | res = 0x8000; | ||
94 | - else | ||
95 | + } else { | ||
96 | res = 0x7fff; | ||
97 | + } | ||
98 | } | ||
99 | return res; | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_sat(uint8_t a, uint8_t b) | ||
102 | |||
103 | res = a - b; | ||
104 | if (((res ^ a) & 0x80) && ((a ^ b) & 0x80)) { | ||
105 | - if (a & 0x80) | ||
106 | + if (a & 0x80) { | ||
107 | res = 0x80; | ||
108 | - else | ||
109 | + } else { | ||
110 | res = 0x7f; | ||
111 | + } | ||
112 | } | ||
113 | return res; | ||
114 | } | ||
115 | @@ -XXX,XX +XXX,XX @@ static inline uint16_t add16_usat(uint16_t a, uint16_t b) | ||
116 | { | ||
117 | uint16_t res; | ||
118 | res = a + b; | ||
119 | - if (res < a) | ||
120 | + if (res < a) { | ||
121 | res = 0xffff; | ||
101 | + } | 122 | + } |
102 | +} | 123 | return res; |
103 | + | 124 | } |
104 | +static void npcm7xx_connect_pwm_fan(NPCM7xxState *soc, SplitIRQ *splitter, | 125 | |
105 | + int fan_no, int output_no) | 126 | static inline uint16_t sub16_usat(uint16_t a, uint16_t b) |
106 | +{ | 127 | { |
107 | + DeviceState *fan; | 128 | - if (a > b) |
108 | + int fan_input; | 129 | + if (a > b) { |
109 | + qemu_irq fan_duty_gpio; | 130 | return a - b; |
110 | + | 131 | - else |
111 | + g_assert(fan_no >= 0 && fan_no <= NPCM7XX_MFT_MAX_FAN_INPUT); | ||
112 | + /* | ||
113 | + * Fan 0~1 belong to module 0 input 0~1. | ||
114 | + * Fan 2~3 belong to module 1 input 0~1. | ||
115 | + * ... | ||
116 | + * Fan 14~15 belong to module 7 input 0~1. | ||
117 | + * Fan 16~17 belong to module 0 input 2~3. | ||
118 | + * Fan 18~19 belong to module 1 input 2~3. | ||
119 | + */ | ||
120 | + if (fan_no < 16) { | ||
121 | + fan = DEVICE(&soc->mft[fan_no / 2]); | ||
122 | + fan_input = fan_no % 2; | ||
123 | + } else { | 132 | + } else { |
124 | + fan = DEVICE(&soc->mft[(fan_no - 16) / 2]); | 133 | return 0; |
125 | + fan_input = fan_no % 2 + 2; | ||
126 | + } | 134 | + } |
127 | + | 135 | } |
128 | + /* Connect the Fan to PWM module */ | 136 | |
129 | + fan_duty_gpio = qdev_get_gpio_in_named(fan, "duty", fan_input); | 137 | static inline uint8_t add8_usat(uint8_t a, uint8_t b) |
130 | + qdev_connect_gpio_out(DEVICE(splitter), output_no, fan_duty_gpio); | ||
131 | +} | ||
132 | + | ||
133 | static void npcm750_evb_i2c_init(NPCM7xxState *soc) | ||
134 | { | 138 | { |
135 | /* lm75 temperature sensor on SVB, tmp105 is compatible */ | 139 | uint8_t res; |
136 | @@ -XXX,XX +XXX,XX @@ static void npcm750_evb_i2c_init(NPCM7xxState *soc) | 140 | res = a + b; |
137 | i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); | 141 | - if (res < a) |
142 | + if (res < a) { | ||
143 | res = 0xff; | ||
144 | + } | ||
145 | return res; | ||
138 | } | 146 | } |
139 | 147 | ||
140 | +static void npcm750_evb_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) | 148 | static inline uint8_t sub8_usat(uint8_t a, uint8_t b) |
141 | +{ | ||
142 | + SplitIRQ *splitter = machine->fan_splitter; | ||
143 | + static const int fan_counts[] = {2, 2, 2, 2, 2, 2, 2, 2}; | ||
144 | + | ||
145 | + npcm7xx_init_pwm_splitter(machine, soc, fan_counts); | ||
146 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x00, 0); | ||
147 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x01, 1); | ||
148 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x02, 0); | ||
149 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x03, 1); | ||
150 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x04, 0); | ||
151 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x05, 1); | ||
152 | + npcm7xx_connect_pwm_fan(soc, &splitter[3], 0x06, 0); | ||
153 | + npcm7xx_connect_pwm_fan(soc, &splitter[3], 0x07, 1); | ||
154 | + npcm7xx_connect_pwm_fan(soc, &splitter[4], 0x08, 0); | ||
155 | + npcm7xx_connect_pwm_fan(soc, &splitter[4], 0x09, 1); | ||
156 | + npcm7xx_connect_pwm_fan(soc, &splitter[5], 0x0a, 0); | ||
157 | + npcm7xx_connect_pwm_fan(soc, &splitter[5], 0x0b, 1); | ||
158 | + npcm7xx_connect_pwm_fan(soc, &splitter[6], 0x0c, 0); | ||
159 | + npcm7xx_connect_pwm_fan(soc, &splitter[6], 0x0d, 1); | ||
160 | + npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0e, 0); | ||
161 | + npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0f, 1); | ||
162 | +} | ||
163 | + | ||
164 | static void quanta_gsj_i2c_init(NPCM7xxState *soc) | ||
165 | { | 149 | { |
166 | /* GSJ machine have 4 max31725 temperature sensors, tmp105 is compatible. */ | 150 | - if (a > b) |
167 | @@ -XXX,XX +XXX,XX @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc) | 151 | + if (a > b) { |
168 | /* TODO: Add additional i2c devices. */ | 152 | return a - b; |
153 | - else | ||
154 | + } else { | ||
155 | return 0; | ||
156 | + } | ||
169 | } | 157 | } |
170 | 158 | ||
171 | +static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) | 159 | #define ADD16(a, b, n) RESULT(add16_usat(a, b), n, 16); |
172 | +{ | 160 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) |
173 | + SplitIRQ *splitter = machine->fan_splitter; | 161 | |
174 | + static const int fan_counts[] = {2, 2, 2, 0, 0, 0, 0, 0}; | 162 | static inline uint8_t do_usad(uint8_t a, uint8_t b) |
175 | + | ||
176 | + npcm7xx_init_pwm_splitter(machine, soc, fan_counts); | ||
177 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x00, 0); | ||
178 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x01, 1); | ||
179 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x02, 0); | ||
180 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x03, 1); | ||
181 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x04, 0); | ||
182 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x05, 1); | ||
183 | +} | ||
184 | + | ||
185 | static void npcm750_evb_init(MachineState *machine) | ||
186 | { | 163 | { |
187 | NPCM7xxState *soc; | 164 | - if (a > b) |
188 | @@ -XXX,XX +XXX,XX @@ static void npcm750_evb_init(MachineState *machine) | 165 | + if (a > b) { |
189 | npcm7xx_load_bootrom(machine, soc); | 166 | return a - b; |
190 | npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0)); | 167 | - else |
191 | npcm750_evb_i2c_init(soc); | 168 | + } else { |
192 | + npcm750_evb_fan_init(NPCM7XX_MACHINE(machine), soc); | 169 | return b - a; |
193 | npcm7xx_load_kernel(machine, soc); | 170 | + } |
194 | } | 171 | } |
195 | 172 | ||
196 | @@ -XXX,XX +XXX,XX @@ static void quanta_gsj_init(MachineState *machine) | 173 | /* Unsigned sum of absolute byte differences. */ |
197 | npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e", | 174 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b) |
198 | drive_get(IF_MTD, 0, 0)); | 175 | uint32_t mask; |
199 | quanta_gsj_i2c_init(soc); | 176 | |
200 | + quanta_gsj_fan_init(NPCM7XX_MACHINE(machine), soc); | 177 | mask = 0; |
201 | npcm7xx_load_kernel(machine, soc); | 178 | - if (flags & 1) |
179 | + if (flags & 1) { | ||
180 | mask |= 0xff; | ||
181 | - if (flags & 2) | ||
182 | + } | ||
183 | + if (flags & 2) { | ||
184 | mask |= 0xff00; | ||
185 | - if (flags & 4) | ||
186 | + } | ||
187 | + if (flags & 4) { | ||
188 | mask |= 0xff0000; | ||
189 | - if (flags & 8) | ||
190 | + } | ||
191 | + if (flags & 8) { | ||
192 | mask |= 0xff000000; | ||
193 | + } | ||
194 | return (a & mask) | (b & ~mask); | ||
202 | } | 195 | } |
203 | 196 | ||
204 | -- | 197 | -- |
205 | 2.20.1 | 198 | 2.25.1 |
206 | |||
207 | diff view generated by jsdifflib |
1 | The pl110_template.h header has a doubly-nested multiple-include pattern: | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | * pl110.c includes it once for each host bit depth (now always 32) | ||
3 | * every time it is included, it includes itself 6 times, to account | ||
4 | for multiple guest device pixel and byte orders | ||
5 | 2 | ||
6 | Now we only have to deal with 32-bit host bit depths, we can move the | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
7 | code corresponding to the outer layer of this double-nesting to be | 4 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
8 | directly in pl110.c and reduce the template header to a single layer | 5 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
9 | of nesting. | 6 | Message-id: 20221213190537.511-5-farosas@suse.de |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | target/arm/m_helper.c | 16 ---------------- | ||
10 | 1 file changed, 16 deletions(-) | ||
10 | 11 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
12 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
13 | Message-id: 20210211141515.8755-3-peter.maydell@linaro.org | ||
14 | --- | ||
15 | hw/display/pl110_template.h | 100 +----------------------------------- | ||
16 | hw/display/pl110.c | 79 ++++++++++++++++++++++++++++ | ||
17 | 2 files changed, 80 insertions(+), 99 deletions(-) | ||
18 | |||
19 | diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/display/pl110_template.h | 14 | --- a/target/arm/m_helper.c |
22 | +++ b/hw/display/pl110_template.h | 15 | +++ b/target/arm/m_helper.c |
23 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
24 | */ | 17 | */ |
25 | 18 | ||
26 | #ifndef ORDER | 19 | #include "qemu/osdep.h" |
27 | - | 20 | -#include "qemu/units.h" |
28 | -#if BITS == 8 | 21 | -#include "target/arm/idau.h" |
29 | -#define COPY_PIXEL(to, from) *(to++) = from | 22 | -#include "trace.h" |
30 | -#elif BITS == 15 || BITS == 16 | 23 | #include "cpu.h" |
31 | -#define COPY_PIXEL(to, from) do { *(uint16_t *)to = from; to += 2; } while (0) | 24 | #include "internals.h" |
32 | -#elif BITS == 24 | 25 | -#include "exec/gdbstub.h" |
33 | -#define COPY_PIXEL(to, from) \ | 26 | #include "exec/helper-proto.h" |
34 | - do { \ | 27 | -#include "qemu/host-utils.h" |
35 | - *(to++) = from; \ | 28 | #include "qemu/main-loop.h" |
36 | - *(to++) = (from) >> 8; \ | 29 | #include "qemu/bitops.h" |
37 | - *(to++) = (from) >> 16; \ | 30 | -#include "qemu/crc32c.h" |
38 | - } while (0) | 31 | -#include "qemu/qemu-print.h" |
39 | -#elif BITS == 32 | 32 | #include "qemu/log.h" |
40 | -#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0) | 33 | #include "exec/exec-all.h" |
41 | -#else | 34 | -#include <zlib.h> /* For crc32 */ |
42 | -#error unknown bit depth | 35 | -#include "semihosting/semihost.h" |
43 | +#error "pl110_template.h is only for inclusion by pl110.c" | 36 | -#include "sysemu/cpus.h" |
37 | -#include "sysemu/kvm.h" | ||
38 | -#include "qemu/range.h" | ||
39 | -#include "qapi/qapi-commands-machine-target.h" | ||
40 | -#include "qapi/error.h" | ||
41 | -#include "qemu/guest-random.h" | ||
42 | #ifdef CONFIG_TCG | ||
43 | -#include "arm_ldst.h" | ||
44 | #include "exec/cpu_ldst.h" | ||
45 | #include "semihosting/common-semi.h" | ||
44 | #endif | 46 | #endif |
45 | |||
46 | -#undef RGB | ||
47 | -#define BORDER bgr | ||
48 | -#define ORDER 0 | ||
49 | -#include "pl110_template.h" | ||
50 | -#define ORDER 1 | ||
51 | -#include "pl110_template.h" | ||
52 | -#define ORDER 2 | ||
53 | -#include "pl110_template.h" | ||
54 | -#undef BORDER | ||
55 | -#define RGB | ||
56 | -#define BORDER rgb | ||
57 | -#define ORDER 0 | ||
58 | -#include "pl110_template.h" | ||
59 | -#define ORDER 1 | ||
60 | -#include "pl110_template.h" | ||
61 | -#define ORDER 2 | ||
62 | -#include "pl110_template.h" | ||
63 | -#undef BORDER | ||
64 | - | ||
65 | -static drawfn glue(pl110_draw_fn_,BITS)[48] = | ||
66 | -{ | ||
67 | - glue(pl110_draw_line1_lblp_bgr,BITS), | ||
68 | - glue(pl110_draw_line2_lblp_bgr,BITS), | ||
69 | - glue(pl110_draw_line4_lblp_bgr,BITS), | ||
70 | - glue(pl110_draw_line8_lblp_bgr,BITS), | ||
71 | - glue(pl110_draw_line16_555_lblp_bgr,BITS), | ||
72 | - glue(pl110_draw_line32_lblp_bgr,BITS), | ||
73 | - glue(pl110_draw_line16_lblp_bgr,BITS), | ||
74 | - glue(pl110_draw_line12_lblp_bgr,BITS), | ||
75 | - | ||
76 | - glue(pl110_draw_line1_bbbp_bgr,BITS), | ||
77 | - glue(pl110_draw_line2_bbbp_bgr,BITS), | ||
78 | - glue(pl110_draw_line4_bbbp_bgr,BITS), | ||
79 | - glue(pl110_draw_line8_bbbp_bgr,BITS), | ||
80 | - glue(pl110_draw_line16_555_bbbp_bgr,BITS), | ||
81 | - glue(pl110_draw_line32_bbbp_bgr,BITS), | ||
82 | - glue(pl110_draw_line16_bbbp_bgr,BITS), | ||
83 | - glue(pl110_draw_line12_bbbp_bgr,BITS), | ||
84 | - | ||
85 | - glue(pl110_draw_line1_lbbp_bgr,BITS), | ||
86 | - glue(pl110_draw_line2_lbbp_bgr,BITS), | ||
87 | - glue(pl110_draw_line4_lbbp_bgr,BITS), | ||
88 | - glue(pl110_draw_line8_lbbp_bgr,BITS), | ||
89 | - glue(pl110_draw_line16_555_lbbp_bgr,BITS), | ||
90 | - glue(pl110_draw_line32_lbbp_bgr,BITS), | ||
91 | - glue(pl110_draw_line16_lbbp_bgr,BITS), | ||
92 | - glue(pl110_draw_line12_lbbp_bgr,BITS), | ||
93 | - | ||
94 | - glue(pl110_draw_line1_lblp_rgb,BITS), | ||
95 | - glue(pl110_draw_line2_lblp_rgb,BITS), | ||
96 | - glue(pl110_draw_line4_lblp_rgb,BITS), | ||
97 | - glue(pl110_draw_line8_lblp_rgb,BITS), | ||
98 | - glue(pl110_draw_line16_555_lblp_rgb,BITS), | ||
99 | - glue(pl110_draw_line32_lblp_rgb,BITS), | ||
100 | - glue(pl110_draw_line16_lblp_rgb,BITS), | ||
101 | - glue(pl110_draw_line12_lblp_rgb,BITS), | ||
102 | - | ||
103 | - glue(pl110_draw_line1_bbbp_rgb,BITS), | ||
104 | - glue(pl110_draw_line2_bbbp_rgb,BITS), | ||
105 | - glue(pl110_draw_line4_bbbp_rgb,BITS), | ||
106 | - glue(pl110_draw_line8_bbbp_rgb,BITS), | ||
107 | - glue(pl110_draw_line16_555_bbbp_rgb,BITS), | ||
108 | - glue(pl110_draw_line32_bbbp_rgb,BITS), | ||
109 | - glue(pl110_draw_line16_bbbp_rgb,BITS), | ||
110 | - glue(pl110_draw_line12_bbbp_rgb,BITS), | ||
111 | - | ||
112 | - glue(pl110_draw_line1_lbbp_rgb,BITS), | ||
113 | - glue(pl110_draw_line2_lbbp_rgb,BITS), | ||
114 | - glue(pl110_draw_line4_lbbp_rgb,BITS), | ||
115 | - glue(pl110_draw_line8_lbbp_rgb,BITS), | ||
116 | - glue(pl110_draw_line16_555_lbbp_rgb,BITS), | ||
117 | - glue(pl110_draw_line32_lbbp_rgb,BITS), | ||
118 | - glue(pl110_draw_line16_lbbp_rgb,BITS), | ||
119 | - glue(pl110_draw_line12_lbbp_rgb,BITS), | ||
120 | -}; | ||
121 | - | ||
122 | -#undef BITS | ||
123 | -#undef COPY_PIXEL | ||
124 | - | ||
125 | -#else | ||
126 | - | ||
127 | #if ORDER == 0 | ||
128 | #define NAME glue(glue(lblp_, BORDER), BITS) | ||
129 | #ifdef HOST_WORDS_BIGENDIAN | ||
130 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_ | ||
131 | #undef NAME | ||
132 | #undef SWAP_WORDS | ||
133 | #undef ORDER | ||
134 | - | ||
135 | -#endif | ||
136 | diff --git a/hw/display/pl110.c b/hw/display/pl110.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/hw/display/pl110.c | ||
139 | +++ b/hw/display/pl110.c | ||
140 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | ||
141 | }; | ||
142 | |||
143 | #define BITS 32 | ||
144 | +#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0) | ||
145 | + | ||
146 | +#undef RGB | ||
147 | +#define BORDER bgr | ||
148 | +#define ORDER 0 | ||
149 | #include "pl110_template.h" | ||
150 | +#define ORDER 1 | ||
151 | +#include "pl110_template.h" | ||
152 | +#define ORDER 2 | ||
153 | +#include "pl110_template.h" | ||
154 | +#undef BORDER | ||
155 | +#define RGB | ||
156 | +#define BORDER rgb | ||
157 | +#define ORDER 0 | ||
158 | +#include "pl110_template.h" | ||
159 | +#define ORDER 1 | ||
160 | +#include "pl110_template.h" | ||
161 | +#define ORDER 2 | ||
162 | +#include "pl110_template.h" | ||
163 | +#undef BORDER | ||
164 | + | ||
165 | +static drawfn pl110_draw_fn_32[48] = { | ||
166 | + pl110_draw_line1_lblp_bgr32, | ||
167 | + pl110_draw_line2_lblp_bgr32, | ||
168 | + pl110_draw_line4_lblp_bgr32, | ||
169 | + pl110_draw_line8_lblp_bgr32, | ||
170 | + pl110_draw_line16_555_lblp_bgr32, | ||
171 | + pl110_draw_line32_lblp_bgr32, | ||
172 | + pl110_draw_line16_lblp_bgr32, | ||
173 | + pl110_draw_line12_lblp_bgr32, | ||
174 | + | ||
175 | + pl110_draw_line1_bbbp_bgr32, | ||
176 | + pl110_draw_line2_bbbp_bgr32, | ||
177 | + pl110_draw_line4_bbbp_bgr32, | ||
178 | + pl110_draw_line8_bbbp_bgr32, | ||
179 | + pl110_draw_line16_555_bbbp_bgr32, | ||
180 | + pl110_draw_line32_bbbp_bgr32, | ||
181 | + pl110_draw_line16_bbbp_bgr32, | ||
182 | + pl110_draw_line12_bbbp_bgr32, | ||
183 | + | ||
184 | + pl110_draw_line1_lbbp_bgr32, | ||
185 | + pl110_draw_line2_lbbp_bgr32, | ||
186 | + pl110_draw_line4_lbbp_bgr32, | ||
187 | + pl110_draw_line8_lbbp_bgr32, | ||
188 | + pl110_draw_line16_555_lbbp_bgr32, | ||
189 | + pl110_draw_line32_lbbp_bgr32, | ||
190 | + pl110_draw_line16_lbbp_bgr32, | ||
191 | + pl110_draw_line12_lbbp_bgr32, | ||
192 | + | ||
193 | + pl110_draw_line1_lblp_rgb32, | ||
194 | + pl110_draw_line2_lblp_rgb32, | ||
195 | + pl110_draw_line4_lblp_rgb32, | ||
196 | + pl110_draw_line8_lblp_rgb32, | ||
197 | + pl110_draw_line16_555_lblp_rgb32, | ||
198 | + pl110_draw_line32_lblp_rgb32, | ||
199 | + pl110_draw_line16_lblp_rgb32, | ||
200 | + pl110_draw_line12_lblp_rgb32, | ||
201 | + | ||
202 | + pl110_draw_line1_bbbp_rgb32, | ||
203 | + pl110_draw_line2_bbbp_rgb32, | ||
204 | + pl110_draw_line4_bbbp_rgb32, | ||
205 | + pl110_draw_line8_bbbp_rgb32, | ||
206 | + pl110_draw_line16_555_bbbp_rgb32, | ||
207 | + pl110_draw_line32_bbbp_rgb32, | ||
208 | + pl110_draw_line16_bbbp_rgb32, | ||
209 | + pl110_draw_line12_bbbp_rgb32, | ||
210 | + | ||
211 | + pl110_draw_line1_lbbp_rgb32, | ||
212 | + pl110_draw_line2_lbbp_rgb32, | ||
213 | + pl110_draw_line4_lbbp_rgb32, | ||
214 | + pl110_draw_line8_lbbp_rgb32, | ||
215 | + pl110_draw_line16_555_lbbp_rgb32, | ||
216 | + pl110_draw_line32_lbbp_rgb32, | ||
217 | + pl110_draw_line16_lbbp_rgb32, | ||
218 | + pl110_draw_line12_lbbp_rgb32, | ||
219 | +}; | ||
220 | + | ||
221 | +#undef BITS | ||
222 | +#undef COPY_PIXEL | ||
223 | + | ||
224 | |||
225 | static int pl110_enabled(PL110State *s) | ||
226 | { | ||
227 | -- | 47 | -- |
228 | 2.20.1 | 48 | 2.25.1 |
229 | |||
230 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Connect the support for the Versal Accelerator RAMs (XRAMs). | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
4 | 4 | Reviewed-by: Claudio Fontana <cfontana@suse.de> | |
5 | Reviewed-by: Luc Michel <luc@lmichel.fr> | 5 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
6 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | 6 | Message-id: 20221213190537.511-6-farosas@suse.de |
7 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Message-id: 20210308224637.2949533-3-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | docs/system/arm/xlnx-versal-virt.rst | 1 + | 9 | target/arm/helper.c | 7 ------- |
12 | include/hw/arm/xlnx-versal.h | 13 ++++++++++ | 10 | 1 file changed, 7 deletions(-) |
13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++ | ||
14 | 3 files changed, 50 insertions(+) | ||
15 | 11 | ||
16 | diff --git a/docs/system/arm/xlnx-versal-virt.rst b/docs/system/arm/xlnx-versal-virt.rst | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/system/arm/xlnx-versal-virt.rst | 14 | --- a/target/arm/helper.c |
19 | +++ b/docs/system/arm/xlnx-versal-virt.rst | 15 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ Implemented devices: | ||
21 | - 8 ADMA (Xilinx zDMA) channels | ||
22 | - 2 SD Controllers | ||
23 | - OCM (256KB of On Chip Memory) | ||
24 | +- XRAM (4MB of on chip Accelerator RAM) | ||
25 | - DDR memory | ||
26 | |||
27 | QEMU does not yet model any other devices, including the PL and the AI Engine. | ||
28 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/include/hw/arm/xlnx-versal.h | ||
31 | +++ b/include/hw/arm/xlnx-versal.h | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | |||
34 | #include "hw/sysbus.h" | ||
35 | #include "hw/arm/boot.h" | ||
36 | +#include "hw/or-irq.h" | ||
37 | #include "hw/sd/sdhci.h" | ||
38 | #include "hw/intc/arm_gicv3.h" | ||
39 | #include "hw/char/pl011.h" | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | #include "hw/rtc/xlnx-zynqmp-rtc.h" | ||
42 | #include "qom/object.h" | ||
43 | #include "hw/usb/xlnx-usb-subsystem.h" | ||
44 | +#include "hw/misc/xlnx-versal-xramc.h" | ||
45 | |||
46 | #define TYPE_XLNX_VERSAL "xlnx-versal" | ||
47 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
48 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
49 | #define XLNX_VERSAL_NR_GEMS 2 | ||
50 | #define XLNX_VERSAL_NR_ADMAS 8 | ||
51 | #define XLNX_VERSAL_NR_SDS 2 | ||
52 | +#define XLNX_VERSAL_NR_XRAM 4 | ||
53 | #define XLNX_VERSAL_NR_IRQS 192 | ||
54 | |||
55 | struct Versal { | ||
56 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
57 | XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS]; | ||
58 | VersalUsb2 usb; | ||
59 | } iou; | ||
60 | + | ||
61 | + struct { | ||
62 | + qemu_or_irq irq_orgate; | ||
63 | + XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
64 | + } xram; | ||
65 | } lpd; | ||
66 | |||
67 | /* The Platform Management Controller subsystem. */ | ||
68 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
69 | #define VERSAL_GEM1_IRQ_0 58 | ||
70 | #define VERSAL_GEM1_WAKE_IRQ_0 59 | ||
71 | #define VERSAL_ADMA_IRQ_0 60 | ||
72 | +#define VERSAL_XRAM_IRQ_0 79 | ||
73 | #define VERSAL_RTC_APB_ERR_IRQ 121 | ||
74 | #define VERSAL_SD0_IRQ_0 126 | ||
75 | #define VERSAL_RTC_ALARM_IRQ 142 | ||
76 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
77 | #define MM_OCM 0xfffc0000U | ||
78 | #define MM_OCM_SIZE 0x40000 | ||
79 | |||
80 | +#define MM_XRAM 0xfe800000 | ||
81 | +#define MM_XRAMC 0xff8e0000 | ||
82 | +#define MM_XRAMC_SIZE 0x10000 | ||
83 | + | ||
84 | #define MM_USB2_CTRL_REGS 0xFF9D0000 | ||
85 | #define MM_USB2_CTRL_REGS_SIZE 0x10000 | ||
86 | |||
87 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/arm/xlnx-versal.c | ||
90 | +++ b/hw/arm/xlnx-versal.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
92 | */ | 17 | */ |
93 | 18 | ||
94 | #include "qemu/osdep.h" | 19 | #include "qemu/osdep.h" |
95 | +#include "qemu/units.h" | 20 | -#include "qemu/units.h" |
21 | #include "qemu/log.h" | ||
22 | #include "trace.h" | ||
23 | #include "cpu.h" | ||
24 | #include "internals.h" | ||
25 | #include "exec/helper-proto.h" | ||
26 | -#include "qemu/host-utils.h" | ||
27 | #include "qemu/main-loop.h" | ||
28 | #include "qemu/timer.h" | ||
29 | #include "qemu/bitops.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #include "exec/exec-all.h" | ||
32 | #include <zlib.h> /* For crc32 */ | ||
33 | #include "hw/irq.h" | ||
34 | -#include "semihosting/semihost.h" | ||
35 | -#include "sysemu/cpus.h" | ||
36 | #include "sysemu/cpu-timers.h" | ||
37 | #include "sysemu/kvm.h" | ||
38 | -#include "qemu/range.h" | ||
39 | #include "qapi/qapi-commands-machine-target.h" | ||
96 | #include "qapi/error.h" | 40 | #include "qapi/error.h" |
97 | #include "qemu/log.h" | 41 | #include "qemu/guest-random.h" |
98 | #include "qemu/module.h" | 42 | #ifdef CONFIG_TCG |
99 | @@ -XXX,XX +XXX,XX @@ static void versal_create_rtc(Versal *s, qemu_irq *pic) | 43 | -#include "arm_ldst.h" |
100 | sysbus_connect_irq(sbd, 1, pic[VERSAL_RTC_APB_ERR_IRQ]); | 44 | -#include "exec/cpu_ldst.h" |
101 | } | 45 | #include "semihosting/common-semi.h" |
102 | 46 | #endif | |
103 | +static void versal_create_xrams(Versal *s, qemu_irq *pic) | 47 | #include "cpregs.h" |
104 | +{ | ||
105 | + int nr_xrams = ARRAY_SIZE(s->lpd.xram.ctrl); | ||
106 | + DeviceState *orgate; | ||
107 | + int i; | ||
108 | + | ||
109 | + /* XRAM IRQs get ORed into a single line. */ | ||
110 | + object_initialize_child(OBJECT(s), "xram-irq-orgate", | ||
111 | + &s->lpd.xram.irq_orgate, TYPE_OR_IRQ); | ||
112 | + orgate = DEVICE(&s->lpd.xram.irq_orgate); | ||
113 | + object_property_set_int(OBJECT(orgate), | ||
114 | + "num-lines", nr_xrams, &error_fatal); | ||
115 | + qdev_realize(orgate, NULL, &error_fatal); | ||
116 | + qdev_connect_gpio_out(orgate, 0, pic[VERSAL_XRAM_IRQ_0]); | ||
117 | + | ||
118 | + for (i = 0; i < ARRAY_SIZE(s->lpd.xram.ctrl); i++) { | ||
119 | + SysBusDevice *sbd; | ||
120 | + MemoryRegion *mr; | ||
121 | + | ||
122 | + object_initialize_child(OBJECT(s), "xram[*]", &s->lpd.xram.ctrl[i], | ||
123 | + TYPE_XLNX_XRAM_CTRL); | ||
124 | + sbd = SYS_BUS_DEVICE(&s->lpd.xram.ctrl[i]); | ||
125 | + sysbus_realize(sbd, &error_fatal); | ||
126 | + | ||
127 | + mr = sysbus_mmio_get_region(sbd, 0); | ||
128 | + memory_region_add_subregion(&s->mr_ps, | ||
129 | + MM_XRAMC + i * MM_XRAMC_SIZE, mr); | ||
130 | + mr = sysbus_mmio_get_region(sbd, 1); | ||
131 | + memory_region_add_subregion(&s->mr_ps, MM_XRAM + i * MiB, mr); | ||
132 | + | ||
133 | + sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(orgate, i)); | ||
134 | + } | ||
135 | +} | ||
136 | + | ||
137 | /* This takes the board allocated linear DDR memory and creates aliases | ||
138 | * for each split DDR range/aperture on the Versal address map. | ||
139 | */ | ||
140 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
141 | versal_create_admas(s, pic); | ||
142 | versal_create_sds(s, pic); | ||
143 | versal_create_rtc(s, pic); | ||
144 | + versal_create_xrams(s, pic); | ||
145 | versal_map_ddr(s); | ||
146 | versal_unimp(s); | ||
147 | |||
148 | -- | 48 | -- |
149 | 2.20.1 | 49 | 2.25.1 |
150 | |||
151 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
2 | 1 | ||
3 | With -Werror=maybe-uninitialized configuration we get | ||
4 | ../hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’: | ||
5 | ../hw/i386/intel_iommu.c:1888:10: error: ‘mask’ may be used | ||
6 | uninitialized in this function [-Werror=maybe-uninitialized] | ||
7 | 1888 | mask = ~mask; | ||
8 | | ~~~~~^~~~~~~ | ||
9 | |||
10 | Add a g_assert_not_reached() to avoid the error. | ||
11 | |||
12 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20210309102742.30442-2-eric.auger@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/i386/intel_iommu.c | 2 ++ | ||
19 | 1 file changed, 2 insertions(+) | ||
20 | |||
21 | diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/i386/intel_iommu.c | ||
24 | +++ b/hw/i386/intel_iommu.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void vtd_context_device_invalidate(IntelIOMMUState *s, | ||
26 | case 3: | ||
27 | mask = 7; /* Mask bit 2:0 in the SID field */ | ||
28 | break; | ||
29 | + default: | ||
30 | + g_assert_not_reached(); | ||
31 | } | ||
32 | mask = ~mask; | ||
33 | |||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The linux kernel 4.20.7 binary for sunxi has been removed from apt.armbian.com: | 3 | Remove some unused headers. |
4 | 4 | ||
5 | $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado --show=app,console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py | 5 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
6 | Fetching asset from tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi | 6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> |
7 | ... | 7 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
8 | (1/6) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi: | 8 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
9 | CANCEL: Missing asset https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb (0.55 s) | 9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
10 | 10 | Message-id: 20221213190537.511-7-farosas@suse.de | |
11 | This commit updates the sunxi kernel to 5.10.16 for the acceptance | 11 | [added back some includes that are still needed at this point] |
12 | tests of the orangepi-pc and cubieboard machines. | 12 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
13 | |||
14 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
15 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
16 | Message-id: 20210310195820.21950-5-nieklinnenbank@gmail.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 14 | --- |
19 | tests/acceptance/boot_linux_console.py | 40 +++++++++++++------------- | 15 | target/arm/cpu.c | 1 - |
20 | tests/acceptance/replay_kernel.py | 8 +++--- | 16 | target/arm/cpu64.c | 6 ------ |
21 | 2 files changed, 24 insertions(+), 24 deletions(-) | 17 | 2 files changed, 7 deletions(-) |
22 | 18 | ||
23 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 19 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
24 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/tests/acceptance/boot_linux_console.py | 21 | --- a/target/arm/cpu.c |
26 | +++ b/tests/acceptance/boot_linux_console.py | 22 | +++ b/target/arm/cpu.c |
27 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): | 23 | @@ -XXX,XX +XXX,XX @@ |
28 | :avocado: tags=machine:cubieboard | 24 | #include "target/arm/idau.h" |
29 | """ | 25 | #include "qemu/module.h" |
30 | deb_url = ('https://apt.armbian.com/pool/main/l/' | 26 | #include "qapi/error.h" |
31 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | 27 | -#include "qapi/visitor.h" |
32 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | 28 | #include "cpu.h" |
33 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | 29 | #ifdef CONFIG_TCG |
34 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | 30 | #include "hw/core/tcg-cpu-ops.h" |
35 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | 31 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
36 | kernel_path = self.extract_from_deb(deb_path, | ||
37 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
38 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' | ||
39 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
40 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' | ||
41 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
42 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
43 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
44 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self): | ||
45 | :avocado: tags=machine:cubieboard | ||
46 | """ | ||
47 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
48 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
49 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
50 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
51 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
52 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
53 | kernel_path = self.extract_from_deb(deb_path, | ||
54 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
55 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' | ||
56 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
57 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' | ||
58 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
59 | rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
60 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
61 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self): | ||
62 | :avocado: tags=machine:orangepi-pc | ||
63 | """ | ||
64 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
65 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
66 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
67 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
68 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
69 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
70 | kernel_path = self.extract_from_deb(deb_path, | ||
71 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
72 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
73 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
74 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
75 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
76 | |||
77 | self.vm.set_console() | ||
78 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self): | ||
79 | :avocado: tags=machine:orangepi-pc | ||
80 | """ | ||
81 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
82 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
83 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
84 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
85 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
86 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
87 | kernel_path = self.extract_from_deb(deb_path, | ||
88 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
89 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
90 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
91 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
92 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
93 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
94 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
95 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): | ||
96 | :avocado: tags=device:sd | ||
97 | """ | ||
98 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
99 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
100 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
101 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
102 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
103 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
104 | kernel_path = self.extract_from_deb(deb_path, | ||
105 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
106 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
107 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
108 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
109 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
110 | rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' | ||
111 | 'kci-2019.02/armel/base/rootfs.ext2.xz') | ||
112 | diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py | ||
113 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
114 | --- a/tests/acceptance/replay_kernel.py | 33 | --- a/target/arm/cpu64.c |
115 | +++ b/tests/acceptance/replay_kernel.py | 34 | +++ b/target/arm/cpu64.c |
116 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): | 35 | @@ -XXX,XX +XXX,XX @@ |
117 | :avocado: tags=machine:cubieboard | 36 | #include "qemu/osdep.h" |
118 | """ | 37 | #include "qapi/error.h" |
119 | deb_url = ('https://apt.armbian.com/pool/main/l/' | 38 | #include "cpu.h" |
120 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | 39 | -#ifdef CONFIG_TCG |
121 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | 40 | -#include "hw/core/tcg-cpu-ops.h" |
122 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | 41 | -#endif /* CONFIG_TCG */ |
123 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | 42 | #include "qemu/module.h" |
124 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | 43 | -#if !defined(CONFIG_USER_ONLY) |
125 | kernel_path = self.extract_from_deb(deb_path, | 44 | -#include "hw/loader.h" |
126 | - '/boot/vmlinuz-4.20.7-sunxi') | 45 | -#endif |
127 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' | 46 | #include "sysemu/kvm.h" |
128 | + '/boot/vmlinuz-5.10.16-sunxi') | 47 | #include "sysemu/hvf.h" |
129 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' | 48 | #include "kvm_arm.h" |
130 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
131 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
132 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
133 | -- | 49 | -- |
134 | 2.20.1 | 50 | 2.25.1 |
135 | |||
136 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The image for Armbian 19.11.3 bionic has been removed from the armbian server. | 3 | The pointed MouseTransformInfo structure is accessed read-only. |
4 | Without the image as input the test arm_orangepi_bionic_19_11 cannot run. | ||
5 | 4 | ||
6 | This commit removes the test completely and merges the code of the generic function | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | do_test_arm_orangepi_uboot_armbian back with the 20.08 test. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 7 | Message-id: 20221220142520.24094-2-philmd@linaro.org | |
9 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
10 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
11 | Message-id: 20210310195820.21950-3-nieklinnenbank@gmail.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | tests/acceptance/boot_linux_console.py | 72 ++++++++------------------ | 10 | include/hw/input/tsc2xxx.h | 4 ++-- |
15 | 1 file changed, 23 insertions(+), 49 deletions(-) | 11 | hw/input/tsc2005.c | 2 +- |
12 | hw/input/tsc210x.c | 3 +-- | ||
13 | 3 files changed, 4 insertions(+), 5 deletions(-) | ||
16 | 14 | ||
17 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 15 | diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/acceptance/boot_linux_console.py | 17 | --- a/include/hw/input/tsc2xxx.h |
20 | +++ b/tests/acceptance/boot_linux_console.py | 18 | +++ b/include/hw/input/tsc2xxx.h |
21 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): | 19 | @@ -XXX,XX +XXX,XX @@ uWireSlave *tsc2102_init(qemu_irq pint); |
22 | # Wait for VM to shut down gracefully | 20 | uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); |
23 | self.vm.wait() | 21 | I2SCodec *tsc210x_codec(uWireSlave *chip); |
24 | 22 | uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | |
25 | - def do_test_arm_orangepi_uboot_armbian(self, image_path): | 23 | -void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info); |
26 | + @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | 24 | +void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info); |
27 | + 'Test artifacts fetched from unreliable apt.armbian.com') | 25 | void tsc210x_key_event(uWireSlave *chip, int key, int down); |
28 | + @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | 26 | |
29 | + def test_arm_orangepi_bionic_20_08(self): | 27 | /* tsc2005.c */ |
30 | + """ | 28 | void *tsc2005_init(qemu_irq pintdav); |
31 | + :avocado: tags=arch:arm | 29 | uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); |
32 | + :avocado: tags=machine:orangepi-pc | 30 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); |
33 | + :avocado: tags=device:sd | 31 | +void tsc2005_set_transform(void *opaque, const MouseTransformInfo *info); |
34 | + """ | 32 | |
35 | + | 33 | #endif |
36 | + # This test download a 275 MiB compressed image and expand it | 34 | diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c |
37 | + # to 1036 MiB, but the underlying filesystem is 1552 MiB... | 35 | index XXXXXXX..XXXXXXX 100644 |
38 | + # As we expand it to 2 GiB we are safe. | 36 | --- a/hw/input/tsc2005.c |
39 | + | 37 | +++ b/hw/input/tsc2005.c |
40 | + image_url = ('https://dl.armbian.com/orangepipc/archive/' | 38 | @@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav) |
41 | + 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') | 39 | * from the touchscreen. Assuming 12-bit precision was used during |
42 | + image_hash = ('b4d6775f5673486329e45a0586bf06b6' | 40 | * tslib calibration. |
43 | + 'dbe792199fd182ac6b9c7bb6c7d3e6dd') | 41 | */ |
44 | + image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, | 42 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info) |
45 | + algorithm='sha256') | 43 | +void tsc2005_set_transform(void *opaque, const MouseTransformInfo *info) |
46 | + image_path = archive.extract(image_path_xz, self.workdir) | 44 | { |
47 | + image_pow2ceil_expand(image_path) | 45 | TSC2005State *s = (TSC2005State *) opaque; |
48 | + | 46 | |
49 | self.vm.set_console() | 47 | diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c |
50 | self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', | 48 | index XXXXXXX..XXXXXXX 100644 |
51 | '-nic', 'user', | 49 | --- a/hw/input/tsc210x.c |
52 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_orangepi_uboot_armbian(self, image_path): | 50 | +++ b/hw/input/tsc210x.c |
53 | 'to <orangepipc>') | 51 | @@ -XXX,XX +XXX,XX @@ I2SCodec *tsc210x_codec(uWireSlave *chip) |
54 | self.wait_for_console_pattern('Starting Load Kernel Modules...') | 52 | * from the touchscreen. Assuming 12-bit precision was used during |
55 | 53 | * tslib calibration. | |
56 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | 54 | */ |
57 | - 'Test artifacts fetched from unreliable apt.armbian.com') | 55 | -void tsc210x_set_transform(uWireSlave *chip, |
58 | - @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | 56 | - MouseTransformInfo *info) |
59 | - @skipUnless(P7ZIP_AVAILABLE, '7z not installed') | 57 | +void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info) |
60 | - def test_arm_orangepi_bionic_19_11(self): | 58 | { |
61 | - """ | 59 | TSC210xState *s = (TSC210xState *) chip->opaque; |
62 | - :avocado: tags=arch:arm | 60 | #if 0 |
63 | - :avocado: tags=machine:orangepi-pc | ||
64 | - :avocado: tags=device:sd | ||
65 | - """ | ||
66 | - | ||
67 | - # This test download a 196MB compressed image and expand it to 1GB | ||
68 | - image_url = ('https://dl.armbian.com/orangepipc/archive/' | ||
69 | - 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z') | ||
70 | - image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e' | ||
71 | - image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash) | ||
72 | - image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img' | ||
73 | - image_path = os.path.join(self.workdir, image_name) | ||
74 | - process.run("7z e -o%s %s" % (self.workdir, image_path_7z)) | ||
75 | - image_pow2ceil_expand(image_path) | ||
76 | - | ||
77 | - self.do_test_arm_orangepi_uboot_armbian(image_path) | ||
78 | - | ||
79 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
80 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
81 | - @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
82 | - def test_arm_orangepi_bionic_20_08(self): | ||
83 | - """ | ||
84 | - :avocado: tags=arch:arm | ||
85 | - :avocado: tags=machine:orangepi-pc | ||
86 | - :avocado: tags=device:sd | ||
87 | - """ | ||
88 | - | ||
89 | - # This test download a 275 MiB compressed image and expand it | ||
90 | - # to 1036 MiB, but the underlying filesystem is 1552 MiB... | ||
91 | - # As we expand it to 2 GiB we are safe. | ||
92 | - | ||
93 | - image_url = ('https://dl.armbian.com/orangepipc/archive/' | ||
94 | - 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') | ||
95 | - image_hash = ('b4d6775f5673486329e45a0586bf06b6' | ||
96 | - 'dbe792199fd182ac6b9c7bb6c7d3e6dd') | ||
97 | - image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, | ||
98 | - algorithm='sha256') | ||
99 | - image_path = archive.extract(image_path_xz, self.workdir) | ||
100 | - image_pow2ceil_expand(image_path) | ||
101 | - | ||
102 | - self.do_test_arm_orangepi_uboot_armbian(image_path) | ||
103 | - | ||
104 | @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
105 | def test_arm_orangepi_uboot_netbsd9(self): | ||
106 | """ | ||
107 | -- | 61 | -- |
108 | 2.20.1 | 62 | 2.25.1 |
109 | 63 | ||
110 | 64 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The virt machine already checks KVM_CAP_ARM_VM_IPA_SIZE to get the | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | upper bound of the IPA size. If that bound is lower than the highest | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | possible GPA for the machine, then QEMU will error out. However, the | 5 | Message-id: 20221220142520.24094-3-philmd@linaro.org |
6 | IPA is set to 40 when the highest GPA is less than or equal to 40, | ||
7 | even when KVM may support an IPA limit as low as 32. This means KVM | ||
8 | may fail the VM creation unnecessarily. Additionally, 40 is selected | ||
9 | with the value 0, which means use the default, and that gets around | ||
10 | a check in some versions of KVM, causing a difficult to debug fail. | ||
11 | Always use the IPA size that corresponds to the highest possible GPA, | ||
12 | unless it's lower than 32, in which case use 32. Also, we must still | ||
13 | use 0 when KVM only supports the legacy fixed 40 bit IPA. | ||
14 | |||
15 | Suggested-by: Marc Zyngier <maz@kernel.org> | ||
16 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
17 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
19 | Message-id: 20210310135218.255205-3-drjones@redhat.com | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 7 | --- |
22 | target/arm/kvm_arm.h | 6 ++++-- | 8 | hw/arm/nseries.c | 18 +++++++++--------- |
23 | hw/arm/virt.c | 23 ++++++++++++++++------- | 9 | 1 file changed, 9 insertions(+), 9 deletions(-) |
24 | target/arm/kvm.c | 4 +++- | ||
25 | 3 files changed, 23 insertions(+), 10 deletions(-) | ||
26 | 10 | ||
27 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
28 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/kvm_arm.h | 13 | --- a/hw/arm/nseries.c |
30 | +++ b/target/arm/kvm_arm.h | 14 | +++ b/hw/arm/nseries.c |
31 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_sve_supported(void); | 15 | @@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s) |
32 | /** | ||
33 | * kvm_arm_get_max_vm_ipa_size: | ||
34 | * @ms: Machine state handle | ||
35 | + * @fixed_ipa: True when the IPA limit is fixed at 40. This is the case | ||
36 | + * for legacy KVM. | ||
37 | * | ||
38 | * Returns the number of bits in the IPA address space supported by KVM | ||
39 | */ | ||
40 | -int kvm_arm_get_max_vm_ipa_size(MachineState *ms); | ||
41 | +int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); | ||
42 | |||
43 | /** | ||
44 | * kvm_arm_sync_mpstate_to_kvm: | ||
45 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_add_vcpu_properties(Object *obj) | ||
46 | g_assert_not_reached(); | ||
47 | } | 16 | } |
48 | 17 | ||
49 | -static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 18 | /* Touchscreen and keypad controller */ |
50 | +static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa) | 19 | -static MouseTransformInfo n800_pointercal = { |
20 | +static const MouseTransformInfo n800_pointercal = { | ||
21 | .x = 800, | ||
22 | .y = 480, | ||
23 | .a = { 14560, -68, -3455208, -39, -9621, 35152972, 65536 }, | ||
24 | }; | ||
25 | |||
26 | -static MouseTransformInfo n810_pointercal = { | ||
27 | +static const MouseTransformInfo n810_pointercal = { | ||
28 | .x = 800, | ||
29 | .y = 480, | ||
30 | .a = { 15041, 148, -4731056, 171, -10238, 35933380, 65536 }, | ||
31 | @@ -XXX,XX +XXX,XX @@ static void n810_key_event(void *opaque, int keycode) | ||
32 | |||
33 | #define M 0 | ||
34 | |||
35 | -static int n810_keys[0x80] = { | ||
36 | +static const int n810_keys[0x80] = { | ||
37 | [0x01] = 16, /* Q */ | ||
38 | [0x02] = 37, /* K */ | ||
39 | [0x03] = 24, /* O */ | ||
40 | @@ -XXX,XX +XXX,XX @@ static void n8x0_usb_setup(struct n800_s *s) | ||
41 | /* Setup done before the main bootloader starts by some early setup code | ||
42 | * - used when we want to run the main bootloader in emulation. This | ||
43 | * isn't documented. */ | ||
44 | -static uint32_t n800_pinout[104] = { | ||
45 | +static const uint32_t n800_pinout[104] = { | ||
46 | 0x080f00d8, 0x00d40808, 0x03080808, 0x080800d0, | ||
47 | 0x00dc0808, 0x0b0f0f00, 0x080800b4, 0x00c00808, | ||
48 | 0x08080808, 0x180800c4, 0x00b80000, 0x08080808, | ||
49 | @@ -XXX,XX +XXX,XX @@ static void n8x0_boot_init(void *opaque) | ||
50 | #define OMAP_TAG_CBUS 0x4e03 | ||
51 | #define OMAP_TAG_EM_ASIC_BB5 0x4e04 | ||
52 | |||
53 | -static struct omap_gpiosw_info_s { | ||
54 | +static const struct omap_gpiosw_info_s { | ||
55 | const char *name; | ||
56 | int line; | ||
57 | int type; | ||
58 | @@ -XXX,XX +XXX,XX @@ static struct omap_gpiosw_info_s { | ||
59 | { NULL } | ||
60 | }; | ||
61 | |||
62 | -static struct omap_partition_info_s { | ||
63 | +static const struct omap_partition_info_s { | ||
64 | uint32_t offset; | ||
65 | uint32_t size; | ||
66 | int mask; | ||
67 | @@ -XXX,XX +XXX,XX @@ static struct omap_partition_info_s { | ||
68 | { 0, 0, 0, NULL } | ||
69 | }; | ||
70 | |||
71 | -static uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR }; | ||
72 | +static const uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR }; | ||
73 | |||
74 | static int n8x0_atag_setup(void *p, int model) | ||
51 | { | 75 | { |
52 | g_assert_not_reached(); | 76 | uint8_t *b; |
53 | } | 77 | uint16_t *w; |
54 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 78 | uint32_t *l; |
55 | index XXXXXXX..XXXXXXX 100644 | 79 | - struct omap_gpiosw_info_s *gpiosw; |
56 | --- a/hw/arm/virt.c | 80 | - struct omap_partition_info_s *partition; |
57 | +++ b/hw/arm/virt.c | 81 | + const struct omap_gpiosw_info_s *gpiosw; |
58 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | 82 | + const struct omap_partition_info_s *partition; |
59 | static int virt_kvm_type(MachineState *ms, const char *type_str) | 83 | const char *tag; |
60 | { | 84 | |
61 | VirtMachineState *vms = VIRT_MACHINE(ms); | 85 | w = p; |
62 | - int max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms); | ||
63 | - int requested_pa_size; | ||
64 | + int max_vm_pa_size, requested_pa_size; | ||
65 | + bool fixed_ipa; | ||
66 | + | ||
67 | + max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa); | ||
68 | |||
69 | /* we freeze the memory map to compute the highest gpa */ | ||
70 | virt_set_memmap(vms); | ||
71 | |||
72 | requested_pa_size = 64 - clz64(vms->highest_gpa); | ||
73 | |||
74 | + /* | ||
75 | + * KVM requires the IPA size to be at least 32 bits. | ||
76 | + */ | ||
77 | + if (requested_pa_size < 32) { | ||
78 | + requested_pa_size = 32; | ||
79 | + } | ||
80 | + | ||
81 | if (requested_pa_size > max_vm_pa_size) { | ||
82 | error_report("-m and ,maxmem option values " | ||
83 | "require an IPA range (%d bits) larger than " | ||
84 | "the one supported by the host (%d bits)", | ||
85 | requested_pa_size, max_vm_pa_size); | ||
86 | - exit(1); | ||
87 | + exit(1); | ||
88 | } | ||
89 | /* | ||
90 | - * By default we return 0 which corresponds to an implicit legacy | ||
91 | - * 40b IPA setting. Otherwise we return the actual requested PA | ||
92 | - * logsize | ||
93 | + * We return the requested PA log size, unless KVM only supports | ||
94 | + * the implicit legacy 40b IPA setting, in which case the kvm_type | ||
95 | + * must be 0. | ||
96 | */ | ||
97 | - return requested_pa_size > 40 ? requested_pa_size : 0; | ||
98 | + return fixed_ipa ? 0 : requested_pa_size; | ||
99 | } | ||
100 | |||
101 | static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
102 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/kvm.c | ||
105 | +++ b/target/arm/kvm.c | ||
106 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(void) | ||
107 | return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3); | ||
108 | } | ||
109 | |||
110 | -int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
111 | +int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa) | ||
112 | { | ||
113 | KVMState *s = KVM_STATE(ms->accelerator); | ||
114 | int ret; | ||
115 | |||
116 | ret = kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE); | ||
117 | + *fixed_ipa = ret <= 0; | ||
118 | + | ||
119 | return ret > 0 ? ret : 40; | ||
120 | } | ||
121 | |||
122 | -- | 86 | -- |
123 | 2.20.1 | 87 | 2.25.1 |
124 | 88 | ||
125 | 89 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds the recently implemented MFT device to the NPCM7XX | 3 | Silent when compiling with -Wextra: |
4 | SoC file. | ||
5 | 4 | ||
6 | Reviewed-by: Doug Evans <dje@google.com> | 5 | ../hw/arm/nseries.c:1081:12: warning: missing field 'line' initializer [-Wmissing-field-initializers] |
7 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | 6 | { NULL } |
8 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | 7 | ^ |
9 | Message-id: 20210311180855.149764-4-wuhaotsh@google.com | 8 | |
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Message-id: 20221220142520.24094-4-philmd@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | docs/system/arm/nuvoton.rst | 2 +- | 14 | hw/arm/nseries.c | 10 ++++------ |
14 | include/hw/arm/npcm7xx.h | 2 ++ | 15 | 1 file changed, 4 insertions(+), 6 deletions(-) |
15 | hw/arm/npcm7xx.c | 45 ++++++++++++++++++++++++++++++------- | ||
16 | 3 files changed, 40 insertions(+), 9 deletions(-) | ||
17 | 16 | ||
18 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst | 17 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/docs/system/arm/nuvoton.rst | 19 | --- a/hw/arm/nseries.c |
21 | +++ b/docs/system/arm/nuvoton.rst | 20 | +++ b/hw/arm/nseries.c |
22 | @@ -XXX,XX +XXX,XX @@ Supported devices | 21 | @@ -XXX,XX +XXX,XX @@ static const struct omap_gpiosw_info_s { |
23 | * Pulse Width Modulation (PWM) | 22 | "headphone", N8X0_HEADPHONE_GPIO, |
24 | * SMBus controller (SMBF) | 23 | OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED, |
25 | * Ethernet controller (EMC) | 24 | }, |
26 | + * Tachometer | 25 | - { NULL } |
27 | 26 | + { /* end of list */ } | |
28 | Missing devices | 27 | }, n810_gpiosw_info[] = { |
29 | --------------- | 28 | { |
30 | @@ -XXX,XX +XXX,XX @@ Missing devices | 29 | "gps_reset", N810_GPS_RESET_GPIO, |
31 | * Peripheral SPI controller (PSPI) | 30 | @@ -XXX,XX +XXX,XX @@ static const struct omap_gpiosw_info_s { |
32 | * SD/MMC host | 31 | "slide", N810_SLIDE_GPIO, |
33 | * PECI interface | 32 | OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED, |
34 | - * Tachometer | 33 | }, |
35 | * PCI and PCIe root complex and bridges | 34 | - { NULL } |
36 | * VDM and MCTP support | 35 | + { /* end of list */ } |
37 | * Serial I/O expansion | ||
38 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/include/hw/arm/npcm7xx.h | ||
41 | +++ b/include/hw/arm/npcm7xx.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #include "hw/mem/npcm7xx_mc.h" | ||
44 | #include "hw/misc/npcm7xx_clk.h" | ||
45 | #include "hw/misc/npcm7xx_gcr.h" | ||
46 | +#include "hw/misc/npcm7xx_mft.h" | ||
47 | #include "hw/misc/npcm7xx_pwm.h" | ||
48 | #include "hw/misc/npcm7xx_rng.h" | ||
49 | #include "hw/net/npcm7xx_emc.h" | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState { | ||
51 | NPCM7xxTimerCtrlState tim[3]; | ||
52 | NPCM7xxADCState adc; | ||
53 | NPCM7xxPWMState pwm[2]; | ||
54 | + NPCM7xxMFTState mft[8]; | ||
55 | NPCM7xxOTPState key_storage; | ||
56 | NPCM7xxOTPState fuse_array; | ||
57 | NPCM7xxMCState mc; | ||
58 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/hw/arm/npcm7xx.c | ||
61 | +++ b/hw/arm/npcm7xx.c | ||
62 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
63 | NPCM7XX_SMBUS15_IRQ, | ||
64 | NPCM7XX_PWM0_IRQ = 93, /* PWM module 0 */ | ||
65 | NPCM7XX_PWM1_IRQ, /* PWM module 1 */ | ||
66 | + NPCM7XX_MFT0_IRQ = 96, /* MFT module 0 */ | ||
67 | + NPCM7XX_MFT1_IRQ, /* MFT module 1 */ | ||
68 | + NPCM7XX_MFT2_IRQ, /* MFT module 2 */ | ||
69 | + NPCM7XX_MFT3_IRQ, /* MFT module 3 */ | ||
70 | + NPCM7XX_MFT4_IRQ, /* MFT module 4 */ | ||
71 | + NPCM7XX_MFT5_IRQ, /* MFT module 5 */ | ||
72 | + NPCM7XX_MFT6_IRQ, /* MFT module 6 */ | ||
73 | + NPCM7XX_MFT7_IRQ, /* MFT module 7 */ | ||
74 | NPCM7XX_EMC2RX_IRQ = 114, | ||
75 | NPCM7XX_EMC2TX_IRQ, | ||
76 | NPCM7XX_GPIO0_IRQ = 116, | ||
77 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_pwm_addr[] = { | ||
78 | 0xf0104000, | ||
79 | }; | 36 | }; |
80 | 37 | ||
81 | +/* Register base address for each MFT Module */ | 38 | static const struct omap_partition_info_s { |
82 | +static const hwaddr npcm7xx_mft_addr[] = { | 39 | @@ -XXX,XX +XXX,XX @@ static const struct omap_partition_info_s { |
83 | + 0xf0180000, | 40 | { 0x00080000, 0x00200000, 0x0, "kernel" }, |
84 | + 0xf0181000, | 41 | { 0x00280000, 0x00200000, 0x3, "initfs" }, |
85 | + 0xf0182000, | 42 | { 0x00480000, 0x0fb80000, 0x3, "rootfs" }, |
86 | + 0xf0183000, | 43 | - |
87 | + 0xf0184000, | 44 | - { 0, 0, 0, NULL } |
88 | + 0xf0185000, | 45 | + { /* end of list */ } |
89 | + 0xf0186000, | 46 | }, n810_part_info[] = { |
90 | + 0xf0187000, | 47 | { 0x00000000, 0x00020000, 0x3, "bootloader" }, |
91 | +}; | 48 | { 0x00020000, 0x00060000, 0x0, "config" }, |
92 | + | 49 | { 0x00080000, 0x00220000, 0x0, "kernel" }, |
93 | /* Direct memory-mapped access to each SMBus Module. */ | 50 | { 0x002a0000, 0x00400000, 0x0, "initfs" }, |
94 | static const hwaddr npcm7xx_smbus_addr[] = { | 51 | { 0x006a0000, 0x0f960000, 0x0, "rootfs" }, |
95 | 0xf0080000, | 52 | - |
96 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj) | 53 | - { 0, 0, 0, NULL } |
97 | object_initialize_child(obj, "pwm[*]", &s->pwm[i], TYPE_NPCM7XX_PWM); | 54 | + { /* end of list */ } |
98 | } | 55 | }; |
99 | 56 | ||
100 | + for (i = 0; i < ARRAY_SIZE(s->mft); i++) { | 57 | static const uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR }; |
101 | + object_initialize_child(obj, "mft[*]", &s->mft[i], TYPE_NPCM7XX_MFT); | ||
102 | + } | ||
103 | + | ||
104 | for (i = 0; i < ARRAY_SIZE(s->emc); i++) { | ||
105 | object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); | ||
106 | } | ||
107 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | ||
108 | sysbus_connect_irq(sbd, i, npcm7xx_irq(s, NPCM7XX_PWM0_IRQ + i)); | ||
109 | } | ||
110 | |||
111 | + /* MFT Modules. Cannot fail. */ | ||
112 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_mft_addr) != ARRAY_SIZE(s->mft)); | ||
113 | + for (i = 0; i < ARRAY_SIZE(s->mft); i++) { | ||
114 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->mft[i]); | ||
115 | + | ||
116 | + qdev_connect_clock_in(DEVICE(&s->mft[i]), "clock-in", | ||
117 | + qdev_get_clock_out(DEVICE(&s->clk), | ||
118 | + "apb4-clock")); | ||
119 | + sysbus_realize(sbd, &error_abort); | ||
120 | + sysbus_mmio_map(sbd, 0, npcm7xx_mft_addr[i]); | ||
121 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, NPCM7XX_MFT0_IRQ + i)); | ||
122 | + } | ||
123 | + | ||
124 | /* | ||
125 | * EMC Modules. Cannot fail. | ||
126 | * The mapping of the device to its netdev backend works as follows: | ||
127 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | ||
128 | create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB); | ||
129 | create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB); | ||
130 | create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); | ||
131 | - create_unimplemented_device("npcm7xx.mft[0]", 0xf0180000, 4 * KiB); | ||
132 | - create_unimplemented_device("npcm7xx.mft[1]", 0xf0181000, 4 * KiB); | ||
133 | - create_unimplemented_device("npcm7xx.mft[2]", 0xf0182000, 4 * KiB); | ||
134 | - create_unimplemented_device("npcm7xx.mft[3]", 0xf0183000, 4 * KiB); | ||
135 | - create_unimplemented_device("npcm7xx.mft[4]", 0xf0184000, 4 * KiB); | ||
136 | - create_unimplemented_device("npcm7xx.mft[5]", 0xf0185000, 4 * KiB); | ||
137 | - create_unimplemented_device("npcm7xx.mft[6]", 0xf0186000, 4 * KiB); | ||
138 | - create_unimplemented_device("npcm7xx.mft[7]", 0xf0187000, 4 * KiB); | ||
139 | create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB); | ||
140 | create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB); | ||
141 | create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); | ||
142 | -- | 58 | -- |
143 | 2.20.1 | 59 | 2.25.1 |
144 | 60 | ||
145 | 61 | diff view generated by jsdifflib |
1 | BITS is always 32, so remove all uses of it from the template header, | 1 | From: Zhuojia Shen <chaosdefinition@hotmail.com> |
---|---|---|---|
2 | by dropping the trailing '32' from the draw function names and | 2 | |
3 | not constructing the name of rgb_to_pixel32() via the glue() macro. | 3 | In CPUID registers exposed to userspace, some registers were missing |
4 | 4 | and some fields were not exposed. This patch aligns exposed ID | |
5 | registers and their fields with what the upstream kernel currently | ||
6 | exposes. | ||
7 | |||
8 | Specifically, the following new ID registers/fields are exposed to | ||
9 | userspace: | ||
10 | |||
11 | ID_AA64PFR1_EL1.BT: bits 3-0 | ||
12 | ID_AA64PFR1_EL1.MTE: bits 11-8 | ||
13 | ID_AA64PFR1_EL1.SME: bits 27-24 | ||
14 | |||
15 | ID_AA64ZFR0_EL1.SVEver: bits 3-0 | ||
16 | ID_AA64ZFR0_EL1.AES: bits 7-4 | ||
17 | ID_AA64ZFR0_EL1.BitPerm: bits 19-16 | ||
18 | ID_AA64ZFR0_EL1.BF16: bits 23-20 | ||
19 | ID_AA64ZFR0_EL1.SHA3: bits 35-32 | ||
20 | ID_AA64ZFR0_EL1.SM4: bits 43-40 | ||
21 | ID_AA64ZFR0_EL1.I8MM: bits 47-44 | ||
22 | ID_AA64ZFR0_EL1.F32MM: bits 55-52 | ||
23 | ID_AA64ZFR0_EL1.F64MM: bits 59-56 | ||
24 | |||
25 | ID_AA64SMFR0_EL1.F32F32: bit 32 | ||
26 | ID_AA64SMFR0_EL1.B16F32: bit 34 | ||
27 | ID_AA64SMFR0_EL1.F16F32: bit 35 | ||
28 | ID_AA64SMFR0_EL1.I8I32: bits 39-36 | ||
29 | ID_AA64SMFR0_EL1.F64F64: bit 48 | ||
30 | ID_AA64SMFR0_EL1.I16I64: bits 55-52 | ||
31 | ID_AA64SMFR0_EL1.FA64: bit 63 | ||
32 | |||
33 | ID_AA64MMFR0_EL1.ECV: bits 63-60 | ||
34 | |||
35 | ID_AA64MMFR1_EL1.AFP: bits 47-44 | ||
36 | |||
37 | ID_AA64MMFR2_EL1.AT: bits 35-32 | ||
38 | |||
39 | ID_AA64ISAR0_EL1.RNDR: bits 63-60 | ||
40 | |||
41 | ID_AA64ISAR1_EL1.FRINTTS: bits 35-32 | ||
42 | ID_AA64ISAR1_EL1.BF16: bits 47-44 | ||
43 | ID_AA64ISAR1_EL1.DGH: bits 51-48 | ||
44 | ID_AA64ISAR1_EL1.I8MM: bits 55-52 | ||
45 | |||
46 | ID_AA64ISAR2_EL1.WFxT: bits 3-0 | ||
47 | ID_AA64ISAR2_EL1.RPRES: bits 7-4 | ||
48 | ID_AA64ISAR2_EL1.GPA3: bits 11-8 | ||
49 | ID_AA64ISAR2_EL1.APA3: bits 15-12 | ||
50 | |||
51 | The code is also refactored to use symbolic names for ID register fields | ||
52 | for better readability and maintainability. | ||
53 | |||
54 | The test case in tests/tcg/aarch64/sysregs.c is also updated to match | ||
55 | the intended behavior. | ||
56 | |||
57 | Signed-off-by: Zhuojia Shen <chaosdefinition@hotmail.com> | ||
58 | Message-id: DS7PR12MB6309FB585E10772928F14271ACE79@DS7PR12MB6309.namprd12.prod.outlook.com | ||
59 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
60 | [PMM: use Sn_n_Cn_Cn_n syntax to work with older assemblers | ||
61 | that don't recognize id_aa64isar2_el1 and id_aa64mmfr2_el1] | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 62 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
7 | Message-id: 20210211141515.8755-4-peter.maydell@linaro.org | ||
8 | --- | 63 | --- |
9 | hw/display/pl110_template.h | 20 +++---- | 64 | target/arm/helper.c | 96 +++++++++++++++++++++++++------ |
10 | hw/display/pl110.c | 113 ++++++++++++++++++------------------ | 65 | tests/tcg/aarch64/sysregs.c | 24 ++++++-- |
11 | 2 files changed, 65 insertions(+), 68 deletions(-) | 66 | tests/tcg/aarch64/Makefile.target | 7 ++- |
12 | 67 | 3 files changed, 103 insertions(+), 24 deletions(-) | |
13 | diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h | 68 | |
69 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 70 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/display/pl110_template.h | 71 | --- a/target/arm/helper.c |
16 | +++ b/hw/display/pl110_template.h | 72 | +++ b/target/arm/helper.c |
73 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
74 | #ifdef CONFIG_USER_ONLY | ||
75 | static const ARMCPRegUserSpaceInfo v8_user_idregs[] = { | ||
76 | { .name = "ID_AA64PFR0_EL1", | ||
77 | - .exported_bits = 0x000f000f00ff0000, | ||
78 | - .fixed_bits = 0x0000000000000011 }, | ||
79 | + .exported_bits = R_ID_AA64PFR0_FP_MASK | | ||
80 | + R_ID_AA64PFR0_ADVSIMD_MASK | | ||
81 | + R_ID_AA64PFR0_SVE_MASK | | ||
82 | + R_ID_AA64PFR0_DIT_MASK, | ||
83 | + .fixed_bits = (0x1u << R_ID_AA64PFR0_EL0_SHIFT) | | ||
84 | + (0x1u << R_ID_AA64PFR0_EL1_SHIFT) }, | ||
85 | { .name = "ID_AA64PFR1_EL1", | ||
86 | - .exported_bits = 0x00000000000000f0 }, | ||
87 | + .exported_bits = R_ID_AA64PFR1_BT_MASK | | ||
88 | + R_ID_AA64PFR1_SSBS_MASK | | ||
89 | + R_ID_AA64PFR1_MTE_MASK | | ||
90 | + R_ID_AA64PFR1_SME_MASK }, | ||
91 | { .name = "ID_AA64PFR*_EL1_RESERVED", | ||
92 | - .is_glob = true }, | ||
93 | - { .name = "ID_AA64ZFR0_EL1" }, | ||
94 | + .is_glob = true }, | ||
95 | + { .name = "ID_AA64ZFR0_EL1", | ||
96 | + .exported_bits = R_ID_AA64ZFR0_SVEVER_MASK | | ||
97 | + R_ID_AA64ZFR0_AES_MASK | | ||
98 | + R_ID_AA64ZFR0_BITPERM_MASK | | ||
99 | + R_ID_AA64ZFR0_BFLOAT16_MASK | | ||
100 | + R_ID_AA64ZFR0_SHA3_MASK | | ||
101 | + R_ID_AA64ZFR0_SM4_MASK | | ||
102 | + R_ID_AA64ZFR0_I8MM_MASK | | ||
103 | + R_ID_AA64ZFR0_F32MM_MASK | | ||
104 | + R_ID_AA64ZFR0_F64MM_MASK }, | ||
105 | + { .name = "ID_AA64SMFR0_EL1", | ||
106 | + .exported_bits = R_ID_AA64SMFR0_F32F32_MASK | | ||
107 | + R_ID_AA64SMFR0_B16F32_MASK | | ||
108 | + R_ID_AA64SMFR0_F16F32_MASK | | ||
109 | + R_ID_AA64SMFR0_I8I32_MASK | | ||
110 | + R_ID_AA64SMFR0_F64F64_MASK | | ||
111 | + R_ID_AA64SMFR0_I16I64_MASK | | ||
112 | + R_ID_AA64SMFR0_FA64_MASK }, | ||
113 | { .name = "ID_AA64MMFR0_EL1", | ||
114 | - .fixed_bits = 0x00000000ff000000 }, | ||
115 | - { .name = "ID_AA64MMFR1_EL1" }, | ||
116 | + .exported_bits = R_ID_AA64MMFR0_ECV_MASK, | ||
117 | + .fixed_bits = (0xfu << R_ID_AA64MMFR0_TGRAN64_SHIFT) | | ||
118 | + (0xfu << R_ID_AA64MMFR0_TGRAN4_SHIFT) }, | ||
119 | + { .name = "ID_AA64MMFR1_EL1", | ||
120 | + .exported_bits = R_ID_AA64MMFR1_AFP_MASK }, | ||
121 | + { .name = "ID_AA64MMFR2_EL1", | ||
122 | + .exported_bits = R_ID_AA64MMFR2_AT_MASK }, | ||
123 | { .name = "ID_AA64MMFR*_EL1_RESERVED", | ||
124 | - .is_glob = true }, | ||
125 | + .is_glob = true }, | ||
126 | { .name = "ID_AA64DFR0_EL1", | ||
127 | - .fixed_bits = 0x0000000000000006 }, | ||
128 | - { .name = "ID_AA64DFR1_EL1" }, | ||
129 | + .fixed_bits = (0x6u << R_ID_AA64DFR0_DEBUGVER_SHIFT) }, | ||
130 | + { .name = "ID_AA64DFR1_EL1" }, | ||
131 | { .name = "ID_AA64DFR*_EL1_RESERVED", | ||
132 | - .is_glob = true }, | ||
133 | + .is_glob = true }, | ||
134 | { .name = "ID_AA64AFR*", | ||
135 | - .is_glob = true }, | ||
136 | + .is_glob = true }, | ||
137 | { .name = "ID_AA64ISAR0_EL1", | ||
138 | - .exported_bits = 0x00fffffff0fffff0 }, | ||
139 | + .exported_bits = R_ID_AA64ISAR0_AES_MASK | | ||
140 | + R_ID_AA64ISAR0_SHA1_MASK | | ||
141 | + R_ID_AA64ISAR0_SHA2_MASK | | ||
142 | + R_ID_AA64ISAR0_CRC32_MASK | | ||
143 | + R_ID_AA64ISAR0_ATOMIC_MASK | | ||
144 | + R_ID_AA64ISAR0_RDM_MASK | | ||
145 | + R_ID_AA64ISAR0_SHA3_MASK | | ||
146 | + R_ID_AA64ISAR0_SM3_MASK | | ||
147 | + R_ID_AA64ISAR0_SM4_MASK | | ||
148 | + R_ID_AA64ISAR0_DP_MASK | | ||
149 | + R_ID_AA64ISAR0_FHM_MASK | | ||
150 | + R_ID_AA64ISAR0_TS_MASK | | ||
151 | + R_ID_AA64ISAR0_RNDR_MASK }, | ||
152 | { .name = "ID_AA64ISAR1_EL1", | ||
153 | - .exported_bits = 0x000000f0ffffffff }, | ||
154 | + .exported_bits = R_ID_AA64ISAR1_DPB_MASK | | ||
155 | + R_ID_AA64ISAR1_APA_MASK | | ||
156 | + R_ID_AA64ISAR1_API_MASK | | ||
157 | + R_ID_AA64ISAR1_JSCVT_MASK | | ||
158 | + R_ID_AA64ISAR1_FCMA_MASK | | ||
159 | + R_ID_AA64ISAR1_LRCPC_MASK | | ||
160 | + R_ID_AA64ISAR1_GPA_MASK | | ||
161 | + R_ID_AA64ISAR1_GPI_MASK | | ||
162 | + R_ID_AA64ISAR1_FRINTTS_MASK | | ||
163 | + R_ID_AA64ISAR1_SB_MASK | | ||
164 | + R_ID_AA64ISAR1_BF16_MASK | | ||
165 | + R_ID_AA64ISAR1_DGH_MASK | | ||
166 | + R_ID_AA64ISAR1_I8MM_MASK }, | ||
167 | + { .name = "ID_AA64ISAR2_EL1", | ||
168 | + .exported_bits = R_ID_AA64ISAR2_WFXT_MASK | | ||
169 | + R_ID_AA64ISAR2_RPRES_MASK | | ||
170 | + R_ID_AA64ISAR2_GPA3_MASK | | ||
171 | + R_ID_AA64ISAR2_APA3_MASK }, | ||
172 | { .name = "ID_AA64ISAR*_EL1_RESERVED", | ||
173 | - .is_glob = true }, | ||
174 | + .is_glob = true }, | ||
175 | }; | ||
176 | modify_arm_cp_regs(v8_idregs, v8_user_idregs); | ||
177 | #endif | ||
178 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
179 | #ifdef CONFIG_USER_ONLY | ||
180 | static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { | ||
181 | { .name = "MIDR_EL1", | ||
182 | - .exported_bits = 0x00000000ffffffff }, | ||
183 | - { .name = "REVIDR_EL1" }, | ||
184 | + .exported_bits = R_MIDR_EL1_REVISION_MASK | | ||
185 | + R_MIDR_EL1_PARTNUM_MASK | | ||
186 | + R_MIDR_EL1_ARCHITECTURE_MASK | | ||
187 | + R_MIDR_EL1_VARIANT_MASK | | ||
188 | + R_MIDR_EL1_IMPLEMENTER_MASK }, | ||
189 | + { .name = "REVIDR_EL1" }, | ||
190 | }; | ||
191 | modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo); | ||
192 | #endif | ||
193 | diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c | ||
194 | index XXXXXXX..XXXXXXX 100644 | ||
195 | --- a/tests/tcg/aarch64/sysregs.c | ||
196 | +++ b/tests/tcg/aarch64/sysregs.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | 197 | @@ -XXX,XX +XXX,XX @@ |
198 | #define HWCAP_CPUID (1 << 11) | ||
18 | #endif | 199 | #endif |
19 | 200 | ||
20 | #if ORDER == 0 | 201 | +/* |
21 | -#define NAME glue(glue(lblp_, BORDER), BITS) | 202 | + * Older assemblers don't recognize newer system register names, |
22 | +#define NAME glue(lblp_, BORDER) | 203 | + * but we can still access them by the Sn_n_Cn_Cn_n syntax. |
23 | #ifdef HOST_WORDS_BIGENDIAN | 204 | + */ |
24 | #define SWAP_WORDS 1 | 205 | +#define SYS_ID_AA64ISAR2_EL1 S3_0_C0_C6_2 |
25 | #endif | 206 | +#define SYS_ID_AA64MMFR2_EL1 S3_0_C0_C7_2 |
26 | #elif ORDER == 1 | 207 | + |
27 | -#define NAME glue(glue(bbbp_, BORDER), BITS) | 208 | int failed_bit_count; |
28 | +#define NAME glue(bbbp_, BORDER) | 209 | |
29 | #ifndef HOST_WORDS_BIGENDIAN | 210 | /* Read and print system register `id' value */ |
30 | #define SWAP_WORDS 1 | 211 | @@ -XXX,XX +XXX,XX @@ int main(void) |
31 | #endif | 212 | * minimum valid fields - for the purposes of this check allowed |
32 | #else | 213 | * to have non-zero values. |
33 | #define SWAP_PIXELS 1 | 214 | */ |
34 | -#define NAME glue(glue(lbbp_, BORDER), BITS) | 215 | - get_cpu_reg_check_mask(id_aa64isar0_el1, _m(00ff,ffff,f0ff,fff0)); |
35 | +#define NAME glue(lbbp_, BORDER) | 216 | - get_cpu_reg_check_mask(id_aa64isar1_el1, _m(0000,00f0,ffff,ffff)); |
36 | #ifdef HOST_WORDS_BIGENDIAN | 217 | + get_cpu_reg_check_mask(id_aa64isar0_el1, _m(f0ff,ffff,f0ff,fff0)); |
37 | #define SWAP_WORDS 1 | 218 | + get_cpu_reg_check_mask(id_aa64isar1_el1, _m(00ff,f0ff,ffff,ffff)); |
38 | #endif | 219 | + get_cpu_reg_check_mask(SYS_ID_AA64ISAR2_EL1, _m(0000,0000,0000,ffff)); |
39 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line16_,NAME)(void *opaque, uint8_t *d, const uint8_ | 220 | /* TGran4 & TGran64 as pegged to -1 */ |
40 | MSB = (data & 0x1f) << 3; | 221 | - get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(0000,0000,ff00,0000)); |
41 | data >>= 5; | 222 | - get_cpu_reg_check_zero(id_aa64mmfr1_el1); |
42 | #endif | 223 | + get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(f000,0000,ff00,0000)); |
43 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | 224 | + get_cpu_reg_check_mask(id_aa64mmfr1_el1, _m(0000,f000,0000,0000)); |
44 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | 225 | + get_cpu_reg_check_mask(SYS_ID_AA64MMFR2_EL1, _m(0000,000f,0000,0000)); |
45 | LSB = (data & 0x1f) << 3; | 226 | /* EL1/EL0 reported as AA64 only */ |
46 | data >>= 5; | 227 | get_cpu_reg_check_mask(id_aa64pfr0_el1, _m(000f,000f,00ff,0011)); |
47 | g = (data & 0x3f) << 2; | 228 | - get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0000,00f0)); |
48 | data >>= 6; | 229 | + get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0f00,0fff)); |
49 | MSB = (data & 0x1f) << 3; | 230 | /* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */ |
50 | data >>= 5; | 231 | get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006)); |
51 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | 232 | get_cpu_reg_check_zero(id_aa64dfr1_el1); |
52 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | 233 | - get_cpu_reg_check_zero(id_aa64zfr0_el1); |
53 | #undef MSB | 234 | + get_cpu_reg_check_mask(id_aa64zfr0_el1, _m(0ff0,ff0f,00ff,00ff)); |
54 | #undef LSB | 235 | +#ifdef HAS_ARMV9_SME |
55 | width -= 2; | 236 | + get_cpu_reg_check_mask(id_aa64smfr0_el1, _m(80f1,00fd,0000,0000)); |
56 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line32_,NAME)(void *opaque, uint8_t *d, const uint8_ | 237 | +#endif |
57 | g = (data >> 16) & 0xff; | 238 | |
58 | MSB = (data >> 8) & 0xff; | 239 | get_cpu_reg_check_zero(id_aa64afr0_el1); |
59 | #endif | 240 | get_cpu_reg_check_zero(id_aa64afr1_el1); |
60 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | 241 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
61 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
62 | #undef MSB | ||
63 | #undef LSB | ||
64 | width--; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line16_555_,NAME)(void *opaque, uint8_t *d, const ui | ||
66 | data >>= 5; | ||
67 | MSB = (data & 0x1f) << 3; | ||
68 | data >>= 5; | ||
69 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
70 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
71 | LSB = (data & 0x1f) << 3; | ||
72 | data >>= 5; | ||
73 | g = (data & 0x1f) << 3; | ||
74 | data >>= 5; | ||
75 | MSB = (data & 0x1f) << 3; | ||
76 | data >>= 6; | ||
77 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
78 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
79 | #undef MSB | ||
80 | #undef LSB | ||
81 | width -= 2; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_ | ||
83 | data >>= 4; | ||
84 | MSB = (data & 0xf) << 4; | ||
85 | data >>= 8; | ||
86 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
87 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
88 | LSB = (data & 0xf) << 4; | ||
89 | data >>= 4; | ||
90 | g = (data & 0xf) << 4; | ||
91 | data >>= 4; | ||
92 | MSB = (data & 0xf) << 4; | ||
93 | data >>= 8; | ||
94 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
95 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
96 | #undef MSB | ||
97 | #undef LSB | ||
98 | width -= 2; | ||
99 | diff --git a/hw/display/pl110.c b/hw/display/pl110.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | 242 | index XXXXXXX..XXXXXXX 100644 |
101 | --- a/hw/display/pl110.c | 243 | --- a/tests/tcg/aarch64/Makefile.target |
102 | +++ b/hw/display/pl110.c | 244 | +++ b/tests/tcg/aarch64/Makefile.target |
103 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | 245 | @@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile |
104 | pl111_id | 246 | $(call cc-option,-march=armv8.1-a+sve2, CROSS_CC_HAS_SVE2); \ |
105 | }; | 247 | $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \ |
106 | 248 | $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \ | |
107 | -#define BITS 32 | 249 | - $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE)) 3> config-cc.mak |
108 | #define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0) | 250 | + $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \ |
109 | 251 | + $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak | |
110 | #undef RGB | 252 | -include config-cc.mak |
111 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | 253 | |
112 | #include "pl110_template.h" | 254 | # Pauth Tests |
113 | #undef BORDER | 255 | @@ -XXX,XX +XXX,XX @@ endif |
114 | 256 | ifneq ($(CROSS_CC_HAS_SVE),) | |
115 | -static drawfn pl110_draw_fn_32[48] = { | 257 | # System Registers Tests |
116 | - pl110_draw_line1_lblp_bgr32, | 258 | AARCH64_TESTS += sysregs |
117 | - pl110_draw_line2_lblp_bgr32, | 259 | +ifneq ($(CROSS_CC_HAS_ARMV9_SME),) |
118 | - pl110_draw_line4_lblp_bgr32, | 260 | +sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME |
119 | - pl110_draw_line8_lblp_bgr32, | 261 | +else |
120 | - pl110_draw_line16_555_lblp_bgr32, | 262 | sysregs: CFLAGS+=-march=armv8.1-a+sve |
121 | - pl110_draw_line32_lblp_bgr32, | 263 | +endif |
122 | - pl110_draw_line16_lblp_bgr32, | 264 | |
123 | - pl110_draw_line12_lblp_bgr32, | 265 | # SVE ioctl test |
124 | - | 266 | AARCH64_TESTS += sve-ioctls |
125 | - pl110_draw_line1_bbbp_bgr32, | ||
126 | - pl110_draw_line2_bbbp_bgr32, | ||
127 | - pl110_draw_line4_bbbp_bgr32, | ||
128 | - pl110_draw_line8_bbbp_bgr32, | ||
129 | - pl110_draw_line16_555_bbbp_bgr32, | ||
130 | - pl110_draw_line32_bbbp_bgr32, | ||
131 | - pl110_draw_line16_bbbp_bgr32, | ||
132 | - pl110_draw_line12_bbbp_bgr32, | ||
133 | - | ||
134 | - pl110_draw_line1_lbbp_bgr32, | ||
135 | - pl110_draw_line2_lbbp_bgr32, | ||
136 | - pl110_draw_line4_lbbp_bgr32, | ||
137 | - pl110_draw_line8_lbbp_bgr32, | ||
138 | - pl110_draw_line16_555_lbbp_bgr32, | ||
139 | - pl110_draw_line32_lbbp_bgr32, | ||
140 | - pl110_draw_line16_lbbp_bgr32, | ||
141 | - pl110_draw_line12_lbbp_bgr32, | ||
142 | - | ||
143 | - pl110_draw_line1_lblp_rgb32, | ||
144 | - pl110_draw_line2_lblp_rgb32, | ||
145 | - pl110_draw_line4_lblp_rgb32, | ||
146 | - pl110_draw_line8_lblp_rgb32, | ||
147 | - pl110_draw_line16_555_lblp_rgb32, | ||
148 | - pl110_draw_line32_lblp_rgb32, | ||
149 | - pl110_draw_line16_lblp_rgb32, | ||
150 | - pl110_draw_line12_lblp_rgb32, | ||
151 | - | ||
152 | - pl110_draw_line1_bbbp_rgb32, | ||
153 | - pl110_draw_line2_bbbp_rgb32, | ||
154 | - pl110_draw_line4_bbbp_rgb32, | ||
155 | - pl110_draw_line8_bbbp_rgb32, | ||
156 | - pl110_draw_line16_555_bbbp_rgb32, | ||
157 | - pl110_draw_line32_bbbp_rgb32, | ||
158 | - pl110_draw_line16_bbbp_rgb32, | ||
159 | - pl110_draw_line12_bbbp_rgb32, | ||
160 | - | ||
161 | - pl110_draw_line1_lbbp_rgb32, | ||
162 | - pl110_draw_line2_lbbp_rgb32, | ||
163 | - pl110_draw_line4_lbbp_rgb32, | ||
164 | - pl110_draw_line8_lbbp_rgb32, | ||
165 | - pl110_draw_line16_555_lbbp_rgb32, | ||
166 | - pl110_draw_line32_lbbp_rgb32, | ||
167 | - pl110_draw_line16_lbbp_rgb32, | ||
168 | - pl110_draw_line12_lbbp_rgb32, | ||
169 | -}; | ||
170 | - | ||
171 | -#undef BITS | ||
172 | #undef COPY_PIXEL | ||
173 | |||
174 | +static drawfn pl110_draw_fn_32[48] = { | ||
175 | + pl110_draw_line1_lblp_bgr, | ||
176 | + pl110_draw_line2_lblp_bgr, | ||
177 | + pl110_draw_line4_lblp_bgr, | ||
178 | + pl110_draw_line8_lblp_bgr, | ||
179 | + pl110_draw_line16_555_lblp_bgr, | ||
180 | + pl110_draw_line32_lblp_bgr, | ||
181 | + pl110_draw_line16_lblp_bgr, | ||
182 | + pl110_draw_line12_lblp_bgr, | ||
183 | + | ||
184 | + pl110_draw_line1_bbbp_bgr, | ||
185 | + pl110_draw_line2_bbbp_bgr, | ||
186 | + pl110_draw_line4_bbbp_bgr, | ||
187 | + pl110_draw_line8_bbbp_bgr, | ||
188 | + pl110_draw_line16_555_bbbp_bgr, | ||
189 | + pl110_draw_line32_bbbp_bgr, | ||
190 | + pl110_draw_line16_bbbp_bgr, | ||
191 | + pl110_draw_line12_bbbp_bgr, | ||
192 | + | ||
193 | + pl110_draw_line1_lbbp_bgr, | ||
194 | + pl110_draw_line2_lbbp_bgr, | ||
195 | + pl110_draw_line4_lbbp_bgr, | ||
196 | + pl110_draw_line8_lbbp_bgr, | ||
197 | + pl110_draw_line16_555_lbbp_bgr, | ||
198 | + pl110_draw_line32_lbbp_bgr, | ||
199 | + pl110_draw_line16_lbbp_bgr, | ||
200 | + pl110_draw_line12_lbbp_bgr, | ||
201 | + | ||
202 | + pl110_draw_line1_lblp_rgb, | ||
203 | + pl110_draw_line2_lblp_rgb, | ||
204 | + pl110_draw_line4_lblp_rgb, | ||
205 | + pl110_draw_line8_lblp_rgb, | ||
206 | + pl110_draw_line16_555_lblp_rgb, | ||
207 | + pl110_draw_line32_lblp_rgb, | ||
208 | + pl110_draw_line16_lblp_rgb, | ||
209 | + pl110_draw_line12_lblp_rgb, | ||
210 | + | ||
211 | + pl110_draw_line1_bbbp_rgb, | ||
212 | + pl110_draw_line2_bbbp_rgb, | ||
213 | + pl110_draw_line4_bbbp_rgb, | ||
214 | + pl110_draw_line8_bbbp_rgb, | ||
215 | + pl110_draw_line16_555_bbbp_rgb, | ||
216 | + pl110_draw_line32_bbbp_rgb, | ||
217 | + pl110_draw_line16_bbbp_rgb, | ||
218 | + pl110_draw_line12_bbbp_rgb, | ||
219 | + | ||
220 | + pl110_draw_line1_lbbp_rgb, | ||
221 | + pl110_draw_line2_lbbp_rgb, | ||
222 | + pl110_draw_line4_lbbp_rgb, | ||
223 | + pl110_draw_line8_lbbp_rgb, | ||
224 | + pl110_draw_line16_555_lbbp_rgb, | ||
225 | + pl110_draw_line32_lbbp_rgb, | ||
226 | + pl110_draw_line16_lbbp_rgb, | ||
227 | + pl110_draw_line12_lbbp_rgb, | ||
228 | +}; | ||
229 | |||
230 | static int pl110_enabled(PL110State *s) | ||
231 | { | ||
232 | -- | 267 | -- |
233 | 2.20.1 | 268 | 2.25.1 |
234 | |||
235 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If the asid is not set, do not attempt to locate the key directly | 3 | This function is not used anywhere outside this file, |
4 | as all inserted keys have a valid asid. | 4 | so we can make the function "static void". |
5 | 5 | ||
6 | Use g_hash_table_foreach_remove instead. | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
8 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | Message-id: 20210309102742.30442-5-eric.auger@redhat.com | 9 | Message-id: 20221216214924.4711-2-philmd@linaro.org |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/arm/smmu-common.c | 2 +- | 12 | include/hw/arm/smmu-common.h | 3 --- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | hw/arm/smmu-common.c | 2 +- |
14 | 2 files changed, 1 insertion(+), 4 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/smmu-common.h | ||
19 | +++ b/include/hw/arm/smmu-common.h | ||
20 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
21 | /* Unmap the range of all the notifiers registered to any IOMMU mr */ | ||
22 | void smmu_inv_notifiers_all(SMMUState *s); | ||
23 | |||
24 | -/* Unmap the range of all the notifiers registered to @mr */ | ||
25 | -void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr); | ||
26 | - | ||
27 | #endif /* HW_ARM_SMMU_COMMON_H */ | ||
16 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | 28 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
17 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/smmu-common.c | 30 | --- a/hw/arm/smmu-common.c |
19 | +++ b/hw/arm/smmu-common.c | 31 | +++ b/hw/arm/smmu-common.c |
20 | @@ -XXX,XX +XXX,XX @@ inline void | 32 | @@ -XXX,XX +XXX,XX @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n) |
21 | smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | 33 | } |
22 | uint8_t tg, uint64_t num_pages, uint8_t ttl) | 34 | |
35 | /* Unmap all notifiers attached to @mr */ | ||
36 | -inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) | ||
37 | +static void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) | ||
23 | { | 38 | { |
24 | - if (ttl && (num_pages == 1)) { | 39 | IOMMUNotifier *n; |
25 | + if (ttl && (num_pages == 1) && (asid >= 0)) { | 40 | |
26 | SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl); | ||
27 | |||
28 | g_hash_table_remove(s->iotlb, &key); | ||
29 | -- | 41 | -- |
30 | 2.20.1 | 42 | 2.25.1 |
31 | 43 | ||
32 | 44 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | As of today, the driver can invalidate a number of pages that is | 3 | When using Clang ("Apple clang version 14.0.0 (clang-1400.0.29.202)") |
4 | not a power of 2. However IOTLB unmap notifications and internal | 4 | and building with -Wall we get: |
5 | IOTLB invalidations work with masks leading to erroneous | ||
6 | invalidations. | ||
7 | 5 | ||
8 | In case the range is not a power of 2, split invalidations into | 6 | hw/arm/smmu-common.c:173:33: warning: static function 'smmu_hash_remove_by_asid_iova' is used in an inline function with external linkage [-Wstatic-in-inline] |
9 | power of 2 invalidations. | 7 | hw/arm/smmu-common.h:170:1: note: use 'static' to give inline function 'smmu_iotlb_inv_iova' internal linkage |
8 | void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
9 | ^ | ||
10 | static | ||
10 | 11 | ||
11 | When looking for a single page entry in the vSMMU internal IOTLB, | 12 | None of our code base require / use inlined functions with external |
12 | let's make sure that if the entry is not found using a | 13 | linkage. Some places use internal inlining in the hot path. These |
13 | g_hash_table_remove() we iterate over all the entries to find a | 14 | two functions are certainly not in any hot path and don't justify |
14 | potential range that overlaps it. | 15 | any inlining, so these are likely oversights rather than intentional. |
15 | 16 | ||
16 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 17 | Reported-by: Stefan Weil <sw@weilnetz.de> |
17 | Message-id: 20210309102742.30442-6-eric.auger@redhat.com | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
22 | Message-id: 20221216214924.4711-3-philmd@linaro.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 24 | --- |
21 | hw/arm/smmu-common.c | 30 ++++++++++++++++++------------ | 25 | hw/arm/smmu-common.c | 13 ++++++------- |
22 | hw/arm/smmuv3.c | 24 ++++++++++++++++++++---- | 26 | 1 file changed, 6 insertions(+), 7 deletions(-) |
23 | 2 files changed, 38 insertions(+), 16 deletions(-) | ||
24 | 27 | ||
25 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | 28 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
26 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/smmu-common.c | 30 | --- a/hw/arm/smmu-common.c |
28 | +++ b/hw/arm/smmu-common.c | 31 | +++ b/hw/arm/smmu-common.c |
29 | @@ -XXX,XX +XXX,XX @@ inline void | 32 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *new) |
30 | smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | 33 | g_hash_table_insert(bs->iotlb, key, new); |
31 | uint8_t tg, uint64_t num_pages, uint8_t ttl) | 34 | } |
35 | |||
36 | -inline void smmu_iotlb_inv_all(SMMUState *s) | ||
37 | +void smmu_iotlb_inv_all(SMMUState *s) | ||
32 | { | 38 | { |
33 | + /* if tg is not set we use 4KB range invalidation */ | 39 | trace_smmu_iotlb_inv_all(); |
34 | + uint8_t granule = tg ? tg * 2 + 10 : 12; | 40 | g_hash_table_remove_all(s->iotlb); |
35 | + | 41 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value, |
36 | if (ttl && (num_pages == 1) && (asid >= 0)) { | 42 | ((entry->iova & ~info->mask) == info->iova); |
37 | SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl); | ||
38 | |||
39 | - g_hash_table_remove(s->iotlb, &key); | ||
40 | - } else { | ||
41 | - /* if tg is not set we use 4KB range invalidation */ | ||
42 | - uint8_t granule = tg ? tg * 2 + 10 : 12; | ||
43 | - | ||
44 | - SMMUIOTLBPageInvInfo info = { | ||
45 | - .asid = asid, .iova = iova, | ||
46 | - .mask = (num_pages * 1 << granule) - 1}; | ||
47 | - | ||
48 | - g_hash_table_foreach_remove(s->iotlb, | ||
49 | - smmu_hash_remove_by_asid_iova, | ||
50 | - &info); | ||
51 | + if (g_hash_table_remove(s->iotlb, &key)) { | ||
52 | + return; | ||
53 | + } | ||
54 | + /* | ||
55 | + * if the entry is not found, let's see if it does not | ||
56 | + * belong to a larger IOTLB entry | ||
57 | + */ | ||
58 | } | ||
59 | + | ||
60 | + SMMUIOTLBPageInvInfo info = { | ||
61 | + .asid = asid, .iova = iova, | ||
62 | + .mask = (num_pages * 1 << granule) - 1}; | ||
63 | + | ||
64 | + g_hash_table_foreach_remove(s->iotlb, | ||
65 | + smmu_hash_remove_by_asid_iova, | ||
66 | + &info); | ||
67 | } | 43 | } |
68 | 44 | ||
69 | inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) | 45 | -inline void |
70 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 46 | -smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, |
71 | index XXXXXXX..XXXXXXX 100644 | 47 | - uint8_t tg, uint64_t num_pages, uint8_t ttl) |
72 | --- a/hw/arm/smmuv3.c | 48 | +void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, |
73 | +++ b/hw/arm/smmuv3.c | 49 | + uint8_t tg, uint64_t num_pages, uint8_t ttl) |
74 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | 50 | { |
75 | uint16_t vmid = CMD_VMID(cmd); | 51 | /* if tg is not set we use 4KB range invalidation */ |
76 | bool leaf = CMD_LEAF(cmd); | 52 | uint8_t granule = tg ? tg * 2 + 10 : 12; |
77 | uint8_t tg = CMD_TG(cmd); | 53 | @@ -XXX,XX +XXX,XX @@ smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, |
78 | - hwaddr num_pages = 1; | 54 | &info); |
79 | + uint64_t first_page = 0, last_page; | ||
80 | + uint64_t num_pages = 1; | ||
81 | int asid = -1; | ||
82 | |||
83 | if (tg) { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
85 | if (type == SMMU_CMD_TLBI_NH_VA) { | ||
86 | asid = CMD_ASID(cmd); | ||
87 | } | ||
88 | - trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | ||
89 | - smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); | ||
90 | - smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl); | ||
91 | + | ||
92 | + /* Split invalidations into ^2 range invalidations */ | ||
93 | + last_page = num_pages - 1; | ||
94 | + while (num_pages) { | ||
95 | + uint8_t granule = tg * 2 + 10; | ||
96 | + uint64_t mask, count; | ||
97 | + | ||
98 | + mask = dma_aligned_pow2_mask(first_page, last_page, 64 - granule); | ||
99 | + count = mask + 1; | ||
100 | + | ||
101 | + trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, count, ttl, leaf); | ||
102 | + smmuv3_inv_notifiers_iova(s, asid, addr, tg, count); | ||
103 | + smmu_iotlb_inv_iova(s, asid, addr, tg, count, ttl); | ||
104 | + | ||
105 | + num_pages -= count; | ||
106 | + first_page += count; | ||
107 | + addr += count * BIT_ULL(granule); | ||
108 | + } | ||
109 | } | 55 | } |
110 | 56 | ||
111 | static int smmuv3_cmdq_consume(SMMUv3State *s) | 57 | -inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) |
58 | +void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) | ||
59 | { | ||
60 | trace_smmu_iotlb_inv_asid(asid); | ||
61 | g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid); | ||
62 | @@ -XXX,XX +XXX,XX @@ error: | ||
63 | * | ||
64 | * return 0 on success | ||
65 | */ | ||
66 | -inline int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, | ||
67 | - SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
68 | +int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, | ||
69 | + SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
70 | { | ||
71 | if (!cfg->aa64) { | ||
72 | /* | ||
112 | -- | 73 | -- |
113 | 2.20.1 | 74 | 2.25.1 |
114 | 75 | ||
115 | 76 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
2 | 1 | ||
3 | Convert all sid printouts to sid=0x%x. | ||
4 | |||
5 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20210309102742.30442-8-eric.auger@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/trace-events | 24 ++++++++++++------------ | ||
11 | 1 file changed, 12 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/trace-events | ||
16 | +++ b/hw/arm/trace-events | ||
17 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_opcode(const char *opcode) "<--- %s" | ||
18 | smmuv3_cmdq_consume_out(uint32_t prod, uint32_t cons, uint8_t prod_wrap, uint8_t cons_wrap) "prod:%d, cons:%d, prod_wrap:%d, cons_wrap:%d " | ||
19 | smmuv3_cmdq_consume_error(const char *cmd_name, uint8_t cmd_error) "Error on %s command execution: %d" | ||
20 | smmuv3_write_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" | ||
21 | -smmuv3_record_event(const char *type, uint32_t sid) "%s sid=%d" | ||
22 | -smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "SID:0x%x features:0x%x, sid_split:0x%x" | ||
23 | +smmuv3_record_event(const char *type, uint32_t sid) "%s sid=0x%x" | ||
24 | +smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "sid=0x%x features:0x%x, sid_split:0x%x" | ||
25 | smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d" | ||
26 | smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64 | ||
27 | -smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" | ||
28 | -smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d STE bypass iova:0x%"PRIx64" is_write=%d" | ||
29 | -smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d abort on iova:0x%"PRIx64" is_write=%d" | ||
30 | -smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" | ||
31 | +smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" | ||
32 | +smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x STE bypass iova:0x%"PRIx64" is_write=%d" | ||
33 | +smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x abort on iova:0x%"PRIx64" is_write=%d" | ||
34 | +smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=0x%x iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" | ||
35 | smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 | ||
36 | smmuv3_decode_cd(uint32_t oas) "oas=%d" | ||
37 | smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz, bool had) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d had:%d" | ||
38 | -smmuv3_cmdq_cfgi_ste(int streamid) "streamid =%d" | ||
39 | +smmuv3_cmdq_cfgi_ste(int streamid) "streamid= 0x%x" | ||
40 | smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x" | ||
41 | -smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" | ||
42 | -smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
43 | -smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
44 | -smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" | ||
45 | +smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x" | ||
46 | +smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" | ||
47 | +smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" | ||
48 | +smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" | ||
49 | smmuv3_cmdq_tlbi_nh(void) "" | ||
50 | smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" | ||
51 | -smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" | ||
52 | +smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x" | ||
53 | smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s" | ||
54 | smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s" | ||
55 | smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64 | ||
56 | -- | ||
57 | 2.20.1 | ||
58 | |||
59 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Since b64ee454a4a0, all predicate operations should be | 3 | So far the GPT timers were unable to raise IRQs to the processor. |
4 | using these field macros for predicates. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | Message-id: 20210309155305.11301-8-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
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/sve_helper.c | 4 ++-- | 9 | include/hw/arm/fsl-imx7.h | 5 +++++ |
12 | target/arm/translate-sve.c | 7 ++++--- | 10 | hw/arm/fsl-imx7.c | 10 ++++++++++ |
13 | 2 files changed, 6 insertions(+), 5 deletions(-) | 11 | 2 files changed, 15 insertions(+) |
14 | 12 | ||
15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 13 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/sve_helper.c | 15 | --- a/include/hw/arm/fsl-imx7.h |
18 | +++ b/target/arm/sve_helper.c | 16 | +++ b/include/hw/arm/fsl-imx7.h |
19 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(sve_cntp)(void *vn, void *vg, uint32_t pred_desc) | 17 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
20 | 18 | FSL_IMX7_USB2_IRQ = 42, | |
21 | uint32_t HELPER(sve_while)(void *vd, uint32_t count, uint32_t pred_desc) | 19 | FSL_IMX7_USB3_IRQ = 40, |
22 | { | 20 | |
23 | - uintptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 21 | + FSL_IMX7_GPT1_IRQ = 55, |
24 | - intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2); | 22 | + FSL_IMX7_GPT2_IRQ = 54, |
25 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | 23 | + FSL_IMX7_GPT3_IRQ = 53, |
26 | + intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); | 24 | + FSL_IMX7_GPT4_IRQ = 52, |
27 | uint64_t esz_mask = pred_esz_masks[esz]; | 25 | + |
28 | ARMPredicateReg *d = vd; | 26 | FSL_IMX7_WDOG1_IRQ = 78, |
29 | uint32_t flags; | 27 | FSL_IMX7_WDOG2_IRQ = 79, |
30 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 28 | FSL_IMX7_WDOG3_IRQ = 10, |
29 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/target/arm/translate-sve.c | 31 | --- a/hw/arm/fsl-imx7.c |
33 | +++ b/target/arm/translate-sve.c | 32 | +++ b/hw/arm/fsl-imx7.c |
34 | @@ -XXX,XX +XXX,XX @@ static bool trans_WHILE(DisasContext *s, arg_WHILE *a) | 33 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
35 | TCGv_i64 op0, op1, t0, t1, tmax; | 34 | FSL_IMX7_GPT4_ADDR, |
36 | TCGv_i32 t2, t3; | 35 | }; |
37 | TCGv_ptr ptr; | 36 | |
38 | - unsigned desc, vsz = vec_full_reg_size(s); | 37 | + static const int FSL_IMX7_GPTn_IRQ[FSL_IMX7_NUM_GPTS] = { |
39 | + unsigned vsz = vec_full_reg_size(s); | 38 | + FSL_IMX7_GPT1_IRQ, |
40 | + unsigned desc = 0; | 39 | + FSL_IMX7_GPT2_IRQ, |
41 | TCGCond cond; | 40 | + FSL_IMX7_GPT3_IRQ, |
42 | 41 | + FSL_IMX7_GPT4_IRQ, | |
43 | if (!sve_access_check(s)) { | 42 | + }; |
44 | @@ -XXX,XX +XXX,XX @@ static bool trans_WHILE(DisasContext *s, arg_WHILE *a) | 43 | + |
45 | /* Scale elements to bits. */ | 44 | s->gpt[i].ccm = IMX_CCM(&s->ccm); |
46 | tcg_gen_shli_i32(t2, t2, a->esz); | 45 | sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &error_abort); |
47 | 46 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, FSL_IMX7_GPTn_ADDR[i]); | |
48 | - desc = (vsz / 8) - 2; | 47 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0, |
49 | - desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz); | 48 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
50 | + desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz / 8); | 49 | + FSL_IMX7_GPTn_IRQ[i])); |
51 | + desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); | 50 | } |
52 | t3 = tcg_const_i32(desc); | 51 | |
53 | 52 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | |
54 | ptr = tcg_temp_new_ptr(); | ||
55 | -- | 53 | -- |
56 | 2.20.1 | 54 | 2.25.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | This patch implements Multi Function Timer (MFT) module for NPCM7XX. | 3 | CCM derived clocks will have to be added later. |
4 | This module is mainly used to configure PWM fans. It has just enough | ||
5 | functionality to make the PWM fan kernel module work. | ||
6 | 4 | ||
7 | The module takes two input, the max_rpm of a fan (modifiable via QMP) | 5 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
8 | and duty cycle (a GPIO from the PWM module.) The actual measured RPM | ||
9 | is equal to max_rpm * duty_cycle / NPCM7XX_PWM_MAX_DUTY. The RPM is | ||
10 | measured as a counter compared to a prescaled input clock. The kernel | ||
11 | driver reads this counter and report to user space. | ||
12 | |||
13 | Refs: | ||
14 | https://github.com/torvalds/linux/blob/master/drivers/hwmon/npcm750-pwm-fan.c | ||
15 | |||
16 | Reviewed-by: Doug Evans <dje@google.com> | ||
17 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
18 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
19 | Message-id: 20210311180855.149764-3-wuhaotsh@google.com | ||
20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 8 | --- |
23 | include/hw/misc/npcm7xx_mft.h | 70 +++++ | 9 | hw/misc/imx7_ccm.c | 49 +++++++++++++++++++++++++++++++++++++--------- |
24 | hw/misc/npcm7xx_mft.c | 540 ++++++++++++++++++++++++++++++++++ | 10 | 1 file changed, 40 insertions(+), 9 deletions(-) |
25 | hw/misc/meson.build | 1 + | ||
26 | hw/misc/trace-events | 8 + | ||
27 | 4 files changed, 619 insertions(+) | ||
28 | create mode 100644 include/hw/misc/npcm7xx_mft.h | ||
29 | create mode 100644 hw/misc/npcm7xx_mft.c | ||
30 | 11 | ||
31 | diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h | 12 | diff --git a/hw/misc/imx7_ccm.c b/hw/misc/imx7_ccm.c |
32 | new file mode 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
33 | index XXXXXXX..XXXXXXX | 14 | --- a/hw/misc/imx7_ccm.c |
34 | --- /dev/null | 15 | +++ b/hw/misc/imx7_ccm.c |
35 | +++ b/include/hw/misc/npcm7xx_mft.h | ||
36 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
37 | +/* | 17 | #include "hw/misc/imx7_ccm.h" |
38 | + * Nuvoton NPCM7xx MFT Module | 18 | #include "migration/vmstate.h" |
39 | + * | 19 | |
40 | + * Copyright 2021 Google LLC | ||
41 | + * | ||
42 | + * This program is free software; you can redistribute it and/or modify it | ||
43 | + * under the terms of the GNU General Public License as published by the | ||
44 | + * Free Software Foundation; either version 2 of the License, or | ||
45 | + * (at your option) any later version. | ||
46 | + * | ||
47 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
48 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
49 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
50 | + * for more details. | ||
51 | + */ | ||
52 | +#ifndef NPCM7XX_MFT_H | ||
53 | +#define NPCM7XX_MFT_H | ||
54 | + | ||
55 | +#include "exec/memory.h" | ||
56 | +#include "hw/clock.h" | ||
57 | +#include "hw/irq.h" | ||
58 | +#include "hw/sysbus.h" | ||
59 | +#include "qom/object.h" | ||
60 | + | ||
61 | +/* Max Fan input number. */ | ||
62 | +#define NPCM7XX_MFT_MAX_FAN_INPUT 19 | ||
63 | + | ||
64 | +/* | ||
65 | + * Number of registers in one MFT module. Don't change this without increasing | ||
66 | + * the version_id in vmstate. | ||
67 | + */ | ||
68 | +#define NPCM7XX_MFT_NR_REGS (0x20 / sizeof(uint16_t)) | ||
69 | + | ||
70 | +/* | ||
71 | + * The MFT can take up to 4 inputs: A0, B0, A1, B1. It can measure one A and one | ||
72 | + * B simultaneously. NPCM7XX_MFT_INASEL and NPCM7XX_MFT_INBSEL are used to | ||
73 | + * select which A or B input are used. | ||
74 | + */ | ||
75 | +#define NPCM7XX_MFT_FANIN_COUNT 4 | ||
76 | + | ||
77 | +/** | ||
78 | + * struct NPCM7xxMFTState - Multi Functional Tachometer device state. | ||
79 | + * @parent: System bus device. | ||
80 | + * @iomem: Memory region through which registers are accessed. | ||
81 | + * @clock_in: The input clock for MFT from CLK module. | ||
82 | + * @clock_{1,2}: The counter clocks for NPCM7XX_MFT_CNT{1,2} | ||
83 | + * @irq: The IRQ for this MFT state. | ||
84 | + * @regs: The MMIO registers. | ||
85 | + * @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1. | ||
86 | + * @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY. | ||
87 | + */ | ||
88 | +typedef struct NPCM7xxMFTState { | ||
89 | + SysBusDevice parent; | ||
90 | + | ||
91 | + MemoryRegion iomem; | ||
92 | + | ||
93 | + Clock *clock_in; | ||
94 | + Clock *clock_1, *clock_2; | ||
95 | + qemu_irq irq; | ||
96 | + uint16_t regs[NPCM7XX_MFT_NR_REGS]; | ||
97 | + | ||
98 | + uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT]; | ||
99 | + uint32_t duty[NPCM7XX_MFT_FANIN_COUNT]; | ||
100 | +} NPCM7xxMFTState; | ||
101 | + | ||
102 | +#define TYPE_NPCM7XX_MFT "npcm7xx-mft" | ||
103 | +#define NPCM7XX_MFT(obj) \ | ||
104 | + OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT) | ||
105 | + | ||
106 | +#endif /* NPCM7XX_MFT_H */ | ||
107 | diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c | ||
108 | new file mode 100644 | ||
109 | index XXXXXXX..XXXXXXX | ||
110 | --- /dev/null | ||
111 | +++ b/hw/misc/npcm7xx_mft.c | ||
112 | @@ -XXX,XX +XXX,XX @@ | ||
113 | +/* | ||
114 | + * Nuvoton NPCM7xx MFT Module | ||
115 | + * | ||
116 | + * Copyright 2021 Google LLC | ||
117 | + * | ||
118 | + * This program is free software; you can redistribute it and/or modify it | ||
119 | + * under the terms of the GNU General Public License as published by the | ||
120 | + * Free Software Foundation; either version 2 of the License, or | ||
121 | + * (at your option) any later version. | ||
122 | + * | ||
123 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
124 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
125 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
126 | + * for more details. | ||
127 | + */ | ||
128 | + | ||
129 | +#include "qemu/osdep.h" | ||
130 | +#include "hw/irq.h" | ||
131 | +#include "hw/qdev-clock.h" | ||
132 | +#include "hw/qdev-properties.h" | ||
133 | +#include "hw/misc/npcm7xx_mft.h" | ||
134 | +#include "hw/misc/npcm7xx_pwm.h" | ||
135 | +#include "hw/registerfields.h" | ||
136 | +#include "migration/vmstate.h" | ||
137 | +#include "qapi/error.h" | ||
138 | +#include "qapi/visitor.h" | ||
139 | +#include "qemu/bitops.h" | ||
140 | +#include "qemu/error-report.h" | ||
141 | +#include "qemu/log.h" | ||
142 | +#include "qemu/module.h" | ||
143 | +#include "qemu/timer.h" | ||
144 | +#include "qemu/units.h" | ||
145 | +#include "trace.h" | 20 | +#include "trace.h" |
146 | + | 21 | + |
147 | +/* | 22 | +#define CKIH_FREQ 24000000 /* 24MHz crystal input */ |
148 | + * Some of the registers can only accessed via 16-bit ops and some can only | ||
149 | + * be accessed via 8-bit ops. However we mark all of them using REG16 to | ||
150 | + * simplify implementation. npcm7xx_mft_check_mem_op checks the access length | ||
151 | + * of memory operations. | ||
152 | + */ | ||
153 | +REG16(NPCM7XX_MFT_CNT1, 0x00); | ||
154 | +REG16(NPCM7XX_MFT_CRA, 0x02); | ||
155 | +REG16(NPCM7XX_MFT_CRB, 0x04); | ||
156 | +REG16(NPCM7XX_MFT_CNT2, 0x06); | ||
157 | +REG16(NPCM7XX_MFT_PRSC, 0x08); | ||
158 | +REG16(NPCM7XX_MFT_CKC, 0x0a); | ||
159 | +REG16(NPCM7XX_MFT_MCTRL, 0x0c); | ||
160 | +REG16(NPCM7XX_MFT_ICTRL, 0x0e); | ||
161 | +REG16(NPCM7XX_MFT_ICLR, 0x10); | ||
162 | +REG16(NPCM7XX_MFT_IEN, 0x12); | ||
163 | +REG16(NPCM7XX_MFT_CPA, 0x14); | ||
164 | +REG16(NPCM7XX_MFT_CPB, 0x16); | ||
165 | +REG16(NPCM7XX_MFT_CPCFG, 0x18); | ||
166 | +REG16(NPCM7XX_MFT_INASEL, 0x1a); | ||
167 | +REG16(NPCM7XX_MFT_INBSEL, 0x1c); | ||
168 | + | 23 | + |
169 | +/* Register Fields */ | 24 | static void imx7_analog_reset(DeviceState *dev) |
170 | +#define NPCM7XX_MFT_CKC_C2CSEL BIT(3) | 25 | { |
171 | +#define NPCM7XX_MFT_CKC_C1CSEL BIT(0) | 26 | IMX7AnalogState *s = IMX7_ANALOG(dev); |
27 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx7_ccm = { | ||
28 | static uint32_t imx7_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
29 | { | ||
30 | /* | ||
31 | - * This function is "consumed" by GPT emulation code, however on | ||
32 | - * i.MX7 each GPT block can have their own clock root. This means | ||
33 | - * that this functions needs somehow to know requester's identity | ||
34 | - * and the way to pass it: be it via additional IMXClk constants | ||
35 | - * or by adding another argument to this method needs to be | ||
36 | - * figured out | ||
37 | + * This function is "consumed" by GPT emulation code. Some clocks | ||
38 | + * have fixed frequencies and we can provide requested frequency | ||
39 | + * easily. However for CCM provided clocks (like IPG) each GPT | ||
40 | + * timer can have its own clock root. | ||
41 | + * This means we need additionnal information when calling this | ||
42 | + * function to know the requester's identity. | ||
43 | */ | ||
44 | - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Not implemented\n", | ||
45 | - TYPE_IMX7_CCM, __func__); | ||
46 | - return 0; | ||
47 | + uint32_t freq = 0; | ||
172 | + | 48 | + |
173 | +#define NPCM7XX_MFT_MCTRL_TBEN BIT(6) | 49 | + switch (clock) { |
174 | +#define NPCM7XX_MFT_MCTRL_TAEN BIT(5) | 50 | + case CLK_NONE: |
175 | +#define NPCM7XX_MFT_MCTRL_TBEDG BIT(4) | 51 | + break; |
176 | +#define NPCM7XX_MFT_MCTRL_TAEDG BIT(3) | 52 | + case CLK_32k: |
177 | +#define NPCM7XX_MFT_MCTRL_MODE5 BIT(2) | 53 | + freq = CKIL_FREQ; |
178 | + | 54 | + break; |
179 | +#define NPCM7XX_MFT_ICTRL_TFPND BIT(5) | 55 | + case CLK_HIGH: |
180 | +#define NPCM7XX_MFT_ICTRL_TEPND BIT(4) | 56 | + freq = CKIH_FREQ; |
181 | +#define NPCM7XX_MFT_ICTRL_TDPND BIT(3) | 57 | + break; |
182 | +#define NPCM7XX_MFT_ICTRL_TCPND BIT(2) | 58 | + case CLK_IPG: |
183 | +#define NPCM7XX_MFT_ICTRL_TBPND BIT(1) | 59 | + case CLK_IPG_HIGH: |
184 | +#define NPCM7XX_MFT_ICTRL_TAPND BIT(0) | 60 | + /* |
185 | + | 61 | + * For now we don't have a way to figure out the device this |
186 | +#define NPCM7XX_MFT_ICLR_TFCLR BIT(5) | 62 | + * function is called for. Until then the IPG derived clocks |
187 | +#define NPCM7XX_MFT_ICLR_TECLR BIT(4) | 63 | + * are left unimplemented. |
188 | +#define NPCM7XX_MFT_ICLR_TDCLR BIT(3) | 64 | + */ |
189 | +#define NPCM7XX_MFT_ICLR_TCCLR BIT(2) | 65 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Clock %d Not implemented\n", |
190 | +#define NPCM7XX_MFT_ICLR_TBCLR BIT(1) | 66 | + TYPE_IMX7_CCM, __func__, clock); |
191 | +#define NPCM7XX_MFT_ICLR_TACLR BIT(0) | 67 | + break; |
192 | + | 68 | + default: |
193 | +#define NPCM7XX_MFT_IEN_TFIEN BIT(5) | 69 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n", |
194 | +#define NPCM7XX_MFT_IEN_TEIEN BIT(4) | 70 | + TYPE_IMX7_CCM, __func__, clock); |
195 | +#define NPCM7XX_MFT_IEN_TDIEN BIT(3) | 71 | + break; |
196 | +#define NPCM7XX_MFT_IEN_TCIEN BIT(2) | ||
197 | +#define NPCM7XX_MFT_IEN_TBIEN BIT(1) | ||
198 | +#define NPCM7XX_MFT_IEN_TAIEN BIT(0) | ||
199 | + | ||
200 | +#define NPCM7XX_MFT_CPCFG_GET_B(rv) extract8((rv), 4, 4) | ||
201 | +#define NPCM7XX_MFT_CPCFG_GET_A(rv) extract8((rv), 0, 4) | ||
202 | +#define NPCM7XX_MFT_CPCFG_HIEN BIT(3) | ||
203 | +#define NPCM7XX_MFT_CPCFG_EQEN BIT(2) | ||
204 | +#define NPCM7XX_MFT_CPCFG_LOEN BIT(1) | ||
205 | +#define NPCM7XX_MFT_CPCFG_CPSEL BIT(0) | ||
206 | + | ||
207 | +#define NPCM7XX_MFT_INASEL_SELA BIT(0) | ||
208 | +#define NPCM7XX_MFT_INBSEL_SELB BIT(0) | ||
209 | + | ||
210 | +/* Max CNT values of the module. The CNT value is a countdown from it. */ | ||
211 | +#define NPCM7XX_MFT_MAX_CNT 0xFFFF | ||
212 | + | ||
213 | +/* Each fan revolution should generated 2 pulses */ | ||
214 | +#define NPCM7XX_MFT_PULSE_PER_REVOLUTION 2 | ||
215 | + | ||
216 | +typedef enum NPCM7xxMFTCaptureState { | ||
217 | + /* capture succeeded with a valid CNT value. */ | ||
218 | + NPCM7XX_CAPTURE_SUCCEED, | ||
219 | + /* capture stopped prematurely due to reaching CPCFG condition. */ | ||
220 | + NPCM7XX_CAPTURE_COMPARE_HIT, | ||
221 | + /* capture fails since it reaches underflow condition for CNT. */ | ||
222 | + NPCM7XX_CAPTURE_UNDERFLOW, | ||
223 | +} NPCM7xxMFTCaptureState; | ||
224 | + | ||
225 | +static void npcm7xx_mft_reset(NPCM7xxMFTState *s) | ||
226 | +{ | ||
227 | + int i; | ||
228 | + | ||
229 | + /* Only registers PRSC ~ INBSEL need to be reset. */ | ||
230 | + for (i = R_NPCM7XX_MFT_PRSC; i <= R_NPCM7XX_MFT_INBSEL; ++i) { | ||
231 | + s->regs[i] = 0; | ||
232 | + } | ||
233 | +} | ||
234 | + | ||
235 | +static void npcm7xx_mft_clear_interrupt(NPCM7xxMFTState *s, uint8_t iclr) | ||
236 | +{ | ||
237 | + /* | ||
238 | + * Clear bits in ICTRL where corresponding bits in iclr is 1. | ||
239 | + * Both iclr and ictrl are 8-bit regs. (See npcm7xx_mft_check_mem_op) | ||
240 | + */ | ||
241 | + s->regs[R_NPCM7XX_MFT_ICTRL] &= ~iclr; | ||
242 | +} | ||
243 | + | ||
244 | +/* | ||
245 | + * If the CPCFG's condition should be triggered during count down from | ||
246 | + * NPCM7XX_MFT_MAX_CNT to src if compared to tgt, return the count when | ||
247 | + * the condition is triggered. | ||
248 | + * Otherwise return -1. | ||
249 | + * Since tgt is uint16_t it must always <= NPCM7XX_MFT_MAX_CNT. | ||
250 | + */ | ||
251 | +static int npcm7xx_mft_compare(int32_t src, uint16_t tgt, uint8_t cpcfg) | ||
252 | +{ | ||
253 | + if (cpcfg & NPCM7XX_MFT_CPCFG_HIEN) { | ||
254 | + return NPCM7XX_MFT_MAX_CNT; | ||
255 | + } | ||
256 | + if ((cpcfg & NPCM7XX_MFT_CPCFG_EQEN) && (src <= tgt)) { | ||
257 | + return tgt; | ||
258 | + } | ||
259 | + if ((cpcfg & NPCM7XX_MFT_CPCFG_LOEN) && (tgt > 0) && (src < tgt)) { | ||
260 | + return tgt - 1; | ||
261 | + } | 72 | + } |
262 | + | 73 | + |
263 | + return -1; | 74 | + trace_ccm_clock_freq(clock, freq); |
264 | +} | ||
265 | + | 75 | + |
266 | +/* Compute CNT according to corresponding fan's RPM. */ | 76 | + return freq; |
267 | +static NPCM7xxMFTCaptureState npcm7xx_mft_compute_cnt( | 77 | } |
268 | + Clock *clock, uint32_t max_rpm, uint32_t duty, uint16_t tgt, | 78 | |
269 | + uint8_t cpcfg, uint16_t *cnt) | 79 | static void imx7_ccm_class_init(ObjectClass *klass, void *data) |
270 | +{ | ||
271 | + uint32_t rpm = (uint64_t)max_rpm * (uint64_t)duty / NPCM7XX_PWM_MAX_DUTY; | ||
272 | + int32_t count; | ||
273 | + int stopped; | ||
274 | + NPCM7xxMFTCaptureState state; | ||
275 | + | ||
276 | + if (rpm == 0) { | ||
277 | + /* | ||
278 | + * If RPM = 0, capture won't happen. CNT will continue count down. | ||
279 | + * So it's effective equivalent to have a cnt > NPCM7XX_MFT_MAX_CNT | ||
280 | + */ | ||
281 | + count = NPCM7XX_MFT_MAX_CNT + 1; | ||
282 | + } else { | ||
283 | + /* | ||
284 | + * RPM = revolution/min. The time for one revlution (in ns) is | ||
285 | + * MINUTE_TO_NANOSECOND / RPM. | ||
286 | + */ | ||
287 | + count = clock_ns_to_ticks(clock, (60 * NANOSECONDS_PER_SECOND) / | ||
288 | + (rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION)); | ||
289 | + } | ||
290 | + | ||
291 | + if (count > NPCM7XX_MFT_MAX_CNT) { | ||
292 | + count = -1; | ||
293 | + } else { | ||
294 | + /* The CNT is a countdown value from NPCM7XX_MFT_MAX_CNT. */ | ||
295 | + count = NPCM7XX_MFT_MAX_CNT - count; | ||
296 | + } | ||
297 | + stopped = npcm7xx_mft_compare(count, tgt, cpcfg); | ||
298 | + if (stopped == -1) { | ||
299 | + if (count == -1) { | ||
300 | + /* Underflow */ | ||
301 | + state = NPCM7XX_CAPTURE_UNDERFLOW; | ||
302 | + } else { | ||
303 | + state = NPCM7XX_CAPTURE_SUCCEED; | ||
304 | + } | ||
305 | + } else { | ||
306 | + count = stopped; | ||
307 | + state = NPCM7XX_CAPTURE_COMPARE_HIT; | ||
308 | + } | ||
309 | + | ||
310 | + if (count != -1) { | ||
311 | + *cnt = count; | ||
312 | + } | ||
313 | + trace_npcm7xx_mft_rpm(clock->canonical_path, clock_get_hz(clock), | ||
314 | + state, count, rpm, duty); | ||
315 | + return state; | ||
316 | +} | ||
317 | + | ||
318 | +/* | ||
319 | + * Capture Fan RPM and update CNT and CR registers accordingly. | ||
320 | + * Raise IRQ if certain contidions are met in IEN. | ||
321 | + */ | ||
322 | +static void npcm7xx_mft_capture(NPCM7xxMFTState *s) | ||
323 | +{ | ||
324 | + int irq_level = 0; | ||
325 | + NPCM7xxMFTCaptureState state; | ||
326 | + int sel; | ||
327 | + uint8_t cpcfg; | ||
328 | + | ||
329 | + /* | ||
330 | + * If not mode 5, the behavior is undefined. We just do nothing in this | ||
331 | + * case. | ||
332 | + */ | ||
333 | + if (!(s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_MODE5)) { | ||
334 | + return; | ||
335 | + } | ||
336 | + | ||
337 | + /* Capture input A. */ | ||
338 | + if (s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_TAEN && | ||
339 | + s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C1CSEL) { | ||
340 | + sel = s->regs[R_NPCM7XX_MFT_INASEL] & NPCM7XX_MFT_INASEL_SELA; | ||
341 | + cpcfg = NPCM7XX_MFT_CPCFG_GET_A(s->regs[R_NPCM7XX_MFT_CPCFG]); | ||
342 | + state = npcm7xx_mft_compute_cnt(s->clock_1, | ||
343 | + sel ? s->max_rpm[2] : s->max_rpm[0], | ||
344 | + sel ? s->duty[2] : s->duty[0], | ||
345 | + s->regs[R_NPCM7XX_MFT_CPA], | ||
346 | + cpcfg, | ||
347 | + &s->regs[R_NPCM7XX_MFT_CNT1]); | ||
348 | + switch (state) { | ||
349 | + case NPCM7XX_CAPTURE_SUCCEED: | ||
350 | + /* Interrupt on input capture on TAn transition - TAPND */ | ||
351 | + s->regs[R_NPCM7XX_MFT_CRA] = s->regs[R_NPCM7XX_MFT_CNT1]; | ||
352 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TAPND; | ||
353 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TAIEN) { | ||
354 | + irq_level = 1; | ||
355 | + } | ||
356 | + break; | ||
357 | + | ||
358 | + case NPCM7XX_CAPTURE_COMPARE_HIT: | ||
359 | + /* Compare Hit - TEPND */ | ||
360 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TEPND; | ||
361 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TEIEN) { | ||
362 | + irq_level = 1; | ||
363 | + } | ||
364 | + break; | ||
365 | + | ||
366 | + case NPCM7XX_CAPTURE_UNDERFLOW: | ||
367 | + /* Underflow - TCPND */ | ||
368 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TCPND; | ||
369 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TCIEN) { | ||
370 | + irq_level = 1; | ||
371 | + } | ||
372 | + break; | ||
373 | + | ||
374 | + default: | ||
375 | + g_assert_not_reached(); | ||
376 | + } | ||
377 | + } | ||
378 | + | ||
379 | + /* Capture input B. */ | ||
380 | + if (s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_TBEN && | ||
381 | + s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C2CSEL) { | ||
382 | + sel = s->regs[R_NPCM7XX_MFT_INBSEL] & NPCM7XX_MFT_INBSEL_SELB; | ||
383 | + cpcfg = NPCM7XX_MFT_CPCFG_GET_B(s->regs[R_NPCM7XX_MFT_CPCFG]); | ||
384 | + state = npcm7xx_mft_compute_cnt(s->clock_2, | ||
385 | + sel ? s->max_rpm[3] : s->max_rpm[1], | ||
386 | + sel ? s->duty[3] : s->duty[1], | ||
387 | + s->regs[R_NPCM7XX_MFT_CPB], | ||
388 | + cpcfg, | ||
389 | + &s->regs[R_NPCM7XX_MFT_CNT2]); | ||
390 | + switch (state) { | ||
391 | + case NPCM7XX_CAPTURE_SUCCEED: | ||
392 | + /* Interrupt on input capture on TBn transition - TBPND */ | ||
393 | + s->regs[R_NPCM7XX_MFT_CRB] = s->regs[R_NPCM7XX_MFT_CNT2]; | ||
394 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TBPND; | ||
395 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TBIEN) { | ||
396 | + irq_level = 1; | ||
397 | + } | ||
398 | + break; | ||
399 | + | ||
400 | + case NPCM7XX_CAPTURE_COMPARE_HIT: | ||
401 | + /* Compare Hit - TFPND */ | ||
402 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TFPND; | ||
403 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TFIEN) { | ||
404 | + irq_level = 1; | ||
405 | + } | ||
406 | + break; | ||
407 | + | ||
408 | + case NPCM7XX_CAPTURE_UNDERFLOW: | ||
409 | + /* Underflow - TDPND */ | ||
410 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TDPND; | ||
411 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TDIEN) { | ||
412 | + irq_level = 1; | ||
413 | + } | ||
414 | + break; | ||
415 | + | ||
416 | + default: | ||
417 | + g_assert_not_reached(); | ||
418 | + } | ||
419 | + } | ||
420 | + | ||
421 | + trace_npcm7xx_mft_capture(DEVICE(s)->canonical_path, irq_level); | ||
422 | + qemu_set_irq(s->irq, irq_level); | ||
423 | +} | ||
424 | + | ||
425 | +/* Update clock for counters. */ | ||
426 | +static void npcm7xx_mft_update_clock(void *opaque, ClockEvent event) | ||
427 | +{ | ||
428 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
429 | + uint64_t prescaled_clock_period; | ||
430 | + | ||
431 | + prescaled_clock_period = clock_get(s->clock_in) * | ||
432 | + (s->regs[R_NPCM7XX_MFT_PRSC] + 1ULL); | ||
433 | + trace_npcm7xx_mft_update_clock(s->clock_in->canonical_path, | ||
434 | + s->regs[R_NPCM7XX_MFT_CKC], | ||
435 | + clock_get(s->clock_in), | ||
436 | + prescaled_clock_period); | ||
437 | + /* Update clock 1 */ | ||
438 | + if (s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C1CSEL) { | ||
439 | + /* Clock is prescaled. */ | ||
440 | + clock_update(s->clock_1, prescaled_clock_period); | ||
441 | + } else { | ||
442 | + /* Clock stopped. */ | ||
443 | + clock_update(s->clock_1, 0); | ||
444 | + } | ||
445 | + /* Update clock 2 */ | ||
446 | + if (s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C2CSEL) { | ||
447 | + /* Clock is prescaled. */ | ||
448 | + clock_update(s->clock_2, prescaled_clock_period); | ||
449 | + } else { | ||
450 | + /* Clock stopped. */ | ||
451 | + clock_update(s->clock_2, 0); | ||
452 | + } | ||
453 | + | ||
454 | + npcm7xx_mft_capture(s); | ||
455 | +} | ||
456 | + | ||
457 | +static uint64_t npcm7xx_mft_read(void *opaque, hwaddr offset, unsigned size) | ||
458 | +{ | ||
459 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
460 | + uint16_t value = 0; | ||
461 | + | ||
462 | + switch (offset) { | ||
463 | + case A_NPCM7XX_MFT_ICLR: | ||
464 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
465 | + "%s: register @ 0x%04" HWADDR_PRIx " is write-only\n", | ||
466 | + __func__, offset); | ||
467 | + break; | ||
468 | + | ||
469 | + default: | ||
470 | + value = s->regs[offset / 2]; | ||
471 | + } | ||
472 | + | ||
473 | + trace_npcm7xx_mft_read(DEVICE(s)->canonical_path, offset, value); | ||
474 | + return value; | ||
475 | +} | ||
476 | + | ||
477 | +static void npcm7xx_mft_write(void *opaque, hwaddr offset, | ||
478 | + uint64_t v, unsigned size) | ||
479 | +{ | ||
480 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
481 | + | ||
482 | + trace_npcm7xx_mft_write(DEVICE(s)->canonical_path, offset, v); | ||
483 | + switch (offset) { | ||
484 | + case A_NPCM7XX_MFT_ICLR: | ||
485 | + npcm7xx_mft_clear_interrupt(s, v); | ||
486 | + break; | ||
487 | + | ||
488 | + case A_NPCM7XX_MFT_CKC: | ||
489 | + case A_NPCM7XX_MFT_PRSC: | ||
490 | + s->regs[offset / 2] = v; | ||
491 | + npcm7xx_mft_update_clock(s, ClockUpdate); | ||
492 | + break; | ||
493 | + | ||
494 | + default: | ||
495 | + s->regs[offset / 2] = v; | ||
496 | + npcm7xx_mft_capture(s); | ||
497 | + break; | ||
498 | + } | ||
499 | +} | ||
500 | + | ||
501 | +static bool npcm7xx_mft_check_mem_op(void *opaque, hwaddr offset, | ||
502 | + unsigned size, bool is_write, | ||
503 | + MemTxAttrs attrs) | ||
504 | +{ | ||
505 | + switch (offset) { | ||
506 | + /* 16-bit registers. Must be accessed with 16-bit read/write.*/ | ||
507 | + case A_NPCM7XX_MFT_CNT1: | ||
508 | + case A_NPCM7XX_MFT_CRA: | ||
509 | + case A_NPCM7XX_MFT_CRB: | ||
510 | + case A_NPCM7XX_MFT_CNT2: | ||
511 | + case A_NPCM7XX_MFT_CPA: | ||
512 | + case A_NPCM7XX_MFT_CPB: | ||
513 | + return size == 2; | ||
514 | + | ||
515 | + /* 8-bit registers. Must be accessed with 8-bit read/write.*/ | ||
516 | + case A_NPCM7XX_MFT_PRSC: | ||
517 | + case A_NPCM7XX_MFT_CKC: | ||
518 | + case A_NPCM7XX_MFT_MCTRL: | ||
519 | + case A_NPCM7XX_MFT_ICTRL: | ||
520 | + case A_NPCM7XX_MFT_ICLR: | ||
521 | + case A_NPCM7XX_MFT_IEN: | ||
522 | + case A_NPCM7XX_MFT_CPCFG: | ||
523 | + case A_NPCM7XX_MFT_INASEL: | ||
524 | + case A_NPCM7XX_MFT_INBSEL: | ||
525 | + return size == 1; | ||
526 | + | ||
527 | + default: | ||
528 | + /* Invalid registers. */ | ||
529 | + return false; | ||
530 | + } | ||
531 | +} | ||
532 | + | ||
533 | +static void npcm7xx_mft_get_max_rpm(Object *obj, Visitor *v, const char *name, | ||
534 | + void *opaque, Error **errp) | ||
535 | +{ | ||
536 | + visit_type_uint32(v, name, (uint32_t *)opaque, errp); | ||
537 | +} | ||
538 | + | ||
539 | +static void npcm7xx_mft_set_max_rpm(Object *obj, Visitor *v, const char *name, | ||
540 | + void *opaque, Error **errp) | ||
541 | +{ | ||
542 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
543 | + uint32_t *max_rpm = opaque; | ||
544 | + uint32_t value; | ||
545 | + | ||
546 | + if (!visit_type_uint32(v, name, &value, errp)) { | ||
547 | + return; | ||
548 | + } | ||
549 | + | ||
550 | + *max_rpm = value; | ||
551 | + npcm7xx_mft_capture(s); | ||
552 | +} | ||
553 | + | ||
554 | +static void npcm7xx_mft_duty_handler(void *opaque, int n, int value) | ||
555 | +{ | ||
556 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
557 | + | ||
558 | + trace_npcm7xx_mft_set_duty(DEVICE(s)->canonical_path, n, value); | ||
559 | + s->duty[n] = value; | ||
560 | + npcm7xx_mft_capture(s); | ||
561 | +} | ||
562 | + | ||
563 | +static const struct MemoryRegionOps npcm7xx_mft_ops = { | ||
564 | + .read = npcm7xx_mft_read, | ||
565 | + .write = npcm7xx_mft_write, | ||
566 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
567 | + .valid = { | ||
568 | + .min_access_size = 1, | ||
569 | + .max_access_size = 2, | ||
570 | + .unaligned = false, | ||
571 | + .accepts = npcm7xx_mft_check_mem_op, | ||
572 | + }, | ||
573 | +}; | ||
574 | + | ||
575 | +static void npcm7xx_mft_enter_reset(Object *obj, ResetType type) | ||
576 | +{ | ||
577 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
578 | + | ||
579 | + npcm7xx_mft_reset(s); | ||
580 | +} | ||
581 | + | ||
582 | +static void npcm7xx_mft_hold_reset(Object *obj) | ||
583 | +{ | ||
584 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
585 | + | ||
586 | + qemu_irq_lower(s->irq); | ||
587 | +} | ||
588 | + | ||
589 | +static void npcm7xx_mft_init(Object *obj) | ||
590 | +{ | ||
591 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
592 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
593 | + DeviceState *dev = DEVICE(obj); | ||
594 | + | ||
595 | + memory_region_init_io(&s->iomem, obj, &npcm7xx_mft_ops, s, | ||
596 | + TYPE_NPCM7XX_MFT, 4 * KiB); | ||
597 | + sysbus_init_mmio(sbd, &s->iomem); | ||
598 | + sysbus_init_irq(sbd, &s->irq); | ||
599 | + s->clock_in = qdev_init_clock_in(dev, "clock-in", npcm7xx_mft_update_clock, | ||
600 | + s, ClockUpdate); | ||
601 | + s->clock_1 = qdev_init_clock_out(dev, "clock1"); | ||
602 | + s->clock_2 = qdev_init_clock_out(dev, "clock2"); | ||
603 | + | ||
604 | + for (int i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) { | ||
605 | + object_property_add(obj, "max_rpm[*]", "uint32", | ||
606 | + npcm7xx_mft_get_max_rpm, | ||
607 | + npcm7xx_mft_set_max_rpm, | ||
608 | + NULL, &s->max_rpm[i]); | ||
609 | + } | ||
610 | + qdev_init_gpio_in_named(dev, npcm7xx_mft_duty_handler, "duty", | ||
611 | + NPCM7XX_MFT_FANIN_COUNT); | ||
612 | +} | ||
613 | + | ||
614 | +static const VMStateDescription vmstate_npcm7xx_mft = { | ||
615 | + .name = "npcm7xx-mft-module", | ||
616 | + .version_id = 0, | ||
617 | + .minimum_version_id = 0, | ||
618 | + .fields = (VMStateField[]) { | ||
619 | + VMSTATE_CLOCK(clock_in, NPCM7xxMFTState), | ||
620 | + VMSTATE_CLOCK(clock_1, NPCM7xxMFTState), | ||
621 | + VMSTATE_CLOCK(clock_2, NPCM7xxMFTState), | ||
622 | + VMSTATE_UINT16_ARRAY(regs, NPCM7xxMFTState, NPCM7XX_MFT_NR_REGS), | ||
623 | + VMSTATE_UINT32_ARRAY(max_rpm, NPCM7xxMFTState, NPCM7XX_MFT_FANIN_COUNT), | ||
624 | + VMSTATE_UINT32_ARRAY(duty, NPCM7xxMFTState, NPCM7XX_MFT_FANIN_COUNT), | ||
625 | + VMSTATE_END_OF_LIST(), | ||
626 | + }, | ||
627 | +}; | ||
628 | + | ||
629 | +static void npcm7xx_mft_class_init(ObjectClass *klass, void *data) | ||
630 | +{ | ||
631 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
632 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
633 | + | ||
634 | + dc->desc = "NPCM7xx MFT Controller"; | ||
635 | + dc->vmsd = &vmstate_npcm7xx_mft; | ||
636 | + rc->phases.enter = npcm7xx_mft_enter_reset; | ||
637 | + rc->phases.hold = npcm7xx_mft_hold_reset; | ||
638 | +} | ||
639 | + | ||
640 | +static const TypeInfo npcm7xx_mft_info = { | ||
641 | + .name = TYPE_NPCM7XX_MFT, | ||
642 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
643 | + .instance_size = sizeof(NPCM7xxMFTState), | ||
644 | + .class_init = npcm7xx_mft_class_init, | ||
645 | + .instance_init = npcm7xx_mft_init, | ||
646 | +}; | ||
647 | + | ||
648 | +static void npcm7xx_mft_register_type(void) | ||
649 | +{ | ||
650 | + type_register_static(&npcm7xx_mft_info); | ||
651 | +} | ||
652 | +type_init(npcm7xx_mft_register_type); | ||
653 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
654 | index XXXXXXX..XXXXXXX 100644 | ||
655 | --- a/hw/misc/meson.build | ||
656 | +++ b/hw/misc/meson.build | ||
657 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mst_fpga.c')) | ||
658 | softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files( | ||
659 | 'npcm7xx_clk.c', | ||
660 | 'npcm7xx_gcr.c', | ||
661 | + 'npcm7xx_mft.c', | ||
662 | 'npcm7xx_pwm.c', | ||
663 | 'npcm7xx_rng.c', | ||
664 | )) | ||
665 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
666 | index XXXXXXX..XXXXXXX 100644 | ||
667 | --- a/hw/misc/trace-events | ||
668 | +++ b/hw/misc/trace-events | ||
669 | @@ -XXX,XX +XXX,XX @@ npcm7xx_clk_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " valu | ||
670 | npcm7xx_gcr_read(uint64_t offset, uint32_t value) " offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 | ||
671 | npcm7xx_gcr_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 | ||
672 | |||
673 | +# npcm7xx_mft.c | ||
674 | +npcm7xx_mft_read(const char *name, uint64_t offset, uint16_t value) "%s: offset: 0x%04" PRIx64 " value: 0x%04" PRIx16 | ||
675 | +npcm7xx_mft_write(const char *name, uint64_t offset, uint16_t value) "%s: offset: 0x%04" PRIx64 " value: 0x%04" PRIx16 | ||
676 | +npcm7xx_mft_rpm(const char *clock, uint32_t clock_hz, int state, int32_t cnt, uint32_t rpm, uint32_t duty) " fan clk: %s clock_hz: %" PRIu32 ", state: %d, cnt: %" PRIi32 ", rpm: %" PRIu32 ", duty: %" PRIu32 | ||
677 | +npcm7xx_mft_capture(const char *name, int irq_level) "%s: level: %d" | ||
678 | +npcm7xx_mft_update_clock(const char *name, uint16_t sel, uint64_t clock_period, uint64_t prescaled_clock_period) "%s: sel: 0x%02" PRIx16 ", period: %" PRIu64 ", prescaled: %" PRIu64 | ||
679 | +npcm7xx_mft_set_duty(const char *name, int n, int value) "%s[%d]: %d" | ||
680 | + | ||
681 | # npcm7xx_rng.c | ||
682 | npcm7xx_rng_read(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u" | ||
683 | npcm7xx_rng_write(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u" | ||
684 | -- | 80 | -- |
685 | 2.20.1 | 81 | 2.25.1 |
686 | |||
687 | diff view generated by jsdifflib |
1 | For a long time now the UI layer has guaranteed that the console | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | surface is always 32 bits per pixel. Remove the legacy dead code | ||
3 | from the pxa2xx_lcd display device which was handling the possibility | ||
4 | that the console surface was some other format. | ||
5 | 2 | ||
3 | The i.MX6UL doesn't support CLK_HIGH ou CLK_HIGH_DIV clock source. | ||
4 | |||
5 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
8 | Message-id: 20210211141515.8755-5-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | hw/display/pxa2xx_lcd.c | 79 +++++++++-------------------------------- | 9 | include/hw/timer/imx_gpt.h | 1 + |
11 | 1 file changed, 17 insertions(+), 62 deletions(-) | 10 | hw/arm/fsl-imx6ul.c | 2 +- |
11 | hw/misc/imx6ul_ccm.c | 6 ------ | ||
12 | hw/timer/imx_gpt.c | 25 +++++++++++++++++++++++++ | ||
13 | 4 files changed, 27 insertions(+), 7 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c | 15 | diff --git a/include/hw/timer/imx_gpt.h b/include/hw/timer/imx_gpt.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/display/pxa2xx_lcd.c | 17 | --- a/include/hw/timer/imx_gpt.h |
16 | +++ b/hw/display/pxa2xx_lcd.c | 18 | +++ b/include/hw/timer/imx_gpt.h |
17 | @@ -XXX,XX +XXX,XX @@ struct PXA2xxLCDState { | 19 | @@ -XXX,XX +XXX,XX @@ |
18 | 20 | #define TYPE_IMX25_GPT "imx25.gpt" | |
19 | int invalidated; | 21 | #define TYPE_IMX31_GPT "imx31.gpt" |
20 | QemuConsole *con; | 22 | #define TYPE_IMX6_GPT "imx6.gpt" |
21 | - drawfn *line_fn[2]; | 23 | +#define TYPE_IMX6UL_GPT "imx6ul.gpt" |
22 | int dest_width; | 24 | #define TYPE_IMX7_GPT "imx7.gpt" |
23 | int xres, yres; | 25 | |
24 | int pal_for; | 26 | #define TYPE_IMX_GPT TYPE_IMX25_GPT |
25 | @@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED { | 27 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
26 | #define LDCMD_SOFINT (1 << 22) | 28 | index XXXXXXX..XXXXXXX 100644 |
27 | #define LDCMD_PAL (1 << 26) | 29 | --- a/hw/arm/fsl-imx6ul.c |
28 | 30 | +++ b/hw/arm/fsl-imx6ul.c | |
29 | +#define BITS 32 | 31 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
30 | +#include "pxa2xx_template.h" | 32 | */ |
33 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
34 | snprintf(name, NAME_SIZE, "gpt%d", i); | ||
35 | - object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX7_GPT); | ||
36 | + object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX6UL_GPT); | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/misc/imx6ul_ccm.c | ||
43 | +++ b/hw/misc/imx6ul_ccm.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx6ul_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
45 | case CLK_32k: | ||
46 | freq = CKIL_FREQ; | ||
47 | break; | ||
48 | - case CLK_HIGH: | ||
49 | - freq = CKIH_FREQ; | ||
50 | - break; | ||
51 | - case CLK_HIGH_DIV: | ||
52 | - freq = CKIH_FREQ / 8; | ||
53 | - break; | ||
54 | default: | ||
55 | qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n", | ||
56 | TYPE_IMX6UL_CCM, __func__, clock); | ||
57 | diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/timer/imx_gpt.c | ||
60 | +++ b/hw/timer/imx_gpt.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static const IMXClk imx6_gpt_clocks[] = { | ||
62 | CLK_HIGH, /* 111 reference clock */ | ||
63 | }; | ||
64 | |||
65 | +static const IMXClk imx6ul_gpt_clocks[] = { | ||
66 | + CLK_NONE, /* 000 No clock source */ | ||
67 | + CLK_IPG, /* 001 ipg_clk, 532MHz*/ | ||
68 | + CLK_IPG_HIGH, /* 010 ipg_clk_highfreq */ | ||
69 | + CLK_EXT, /* 011 External clock */ | ||
70 | + CLK_32k, /* 100 ipg_clk_32k */ | ||
71 | + CLK_NONE, /* 101 not defined */ | ||
72 | + CLK_NONE, /* 110 not defined */ | ||
73 | + CLK_NONE, /* 111 not defined */ | ||
74 | +}; | ||
31 | + | 75 | + |
32 | /* Route internal interrupt lines to the global IC */ | 76 | static const IMXClk imx7_gpt_clocks[] = { |
33 | static void pxa2xx_lcdc_int_update(PXA2xxLCDState *s) | 77 | CLK_NONE, /* 000 No clock source */ |
34 | { | 78 | CLK_IPG, /* 001 ipg_clk, 532MHz*/ |
35 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) | 79 | @@ -XXX,XX +XXX,XX @@ static void imx6_gpt_init(Object *obj) |
36 | } | 80 | s->clocks = imx6_gpt_clocks; |
37 | } | 81 | } |
38 | 82 | ||
39 | +static inline drawfn pxa2xx_drawfn(PXA2xxLCDState *s) | 83 | +static void imx6ul_gpt_init(Object *obj) |
40 | +{ | 84 | +{ |
41 | + if (s->transp) { | 85 | + IMXGPTState *s = IMX_GPT(obj); |
42 | + return pxa2xx_draw_fn_32t[s->bpp]; | 86 | + |
43 | + } else { | 87 | + s->clocks = imx6ul_gpt_clocks; |
44 | + return pxa2xx_draw_fn_32[s->bpp]; | ||
45 | + } | ||
46 | +} | 88 | +} |
47 | + | 89 | + |
48 | static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s, | 90 | static void imx7_gpt_init(Object *obj) |
49 | hwaddr addr, int *miny, int *maxy) | ||
50 | { | 91 | { |
51 | DisplaySurface *surface = qemu_console_surface(s->con); | 92 | IMXGPTState *s = IMX_GPT(obj); |
52 | int src_width, dest_width; | 93 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo imx6_gpt_info = { |
53 | - drawfn fn = NULL; | 94 | .instance_init = imx6_gpt_init, |
54 | - if (s->dest_width) | ||
55 | - fn = s->line_fn[s->transp][s->bpp]; | ||
56 | + drawfn fn = pxa2xx_drawfn(s); | ||
57 | if (!fn) | ||
58 | return; | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, | ||
61 | { | ||
62 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
63 | int src_width, dest_width; | ||
64 | - drawfn fn = NULL; | ||
65 | - if (s->dest_width) | ||
66 | - fn = s->line_fn[s->transp][s->bpp]; | ||
67 | + drawfn fn = pxa2xx_drawfn(s); | ||
68 | if (!fn) | ||
69 | return; | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s, | ||
72 | { | ||
73 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
74 | int src_width, dest_width; | ||
75 | - drawfn fn = NULL; | ||
76 | - if (s->dest_width) { | ||
77 | - fn = s->line_fn[s->transp][s->bpp]; | ||
78 | - } | ||
79 | + drawfn fn = pxa2xx_drawfn(s); | ||
80 | if (!fn) { | ||
81 | return; | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, | ||
84 | { | ||
85 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
86 | int src_width, dest_width; | ||
87 | - drawfn fn = NULL; | ||
88 | - if (s->dest_width) { | ||
89 | - fn = s->line_fn[s->transp][s->bpp]; | ||
90 | - } | ||
91 | + drawfn fn = pxa2xx_drawfn(s); | ||
92 | if (!fn) { | ||
93 | return; | ||
94 | } | ||
95 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pxa2xx_lcdc = { | ||
96 | } | ||
97 | }; | 95 | }; |
98 | 96 | ||
99 | -#define BITS 8 | 97 | +static const TypeInfo imx6ul_gpt_info = { |
100 | -#include "pxa2xx_template.h" | 98 | + .name = TYPE_IMX6UL_GPT, |
101 | -#define BITS 15 | 99 | + .parent = TYPE_IMX25_GPT, |
102 | -#include "pxa2xx_template.h" | 100 | + .instance_init = imx6ul_gpt_init, |
103 | -#define BITS 16 | 101 | +}; |
104 | -#include "pxa2xx_template.h" | 102 | + |
105 | -#define BITS 24 | 103 | static const TypeInfo imx7_gpt_info = { |
106 | -#include "pxa2xx_template.h" | 104 | .name = TYPE_IMX7_GPT, |
107 | -#define BITS 32 | 105 | .parent = TYPE_IMX25_GPT, |
108 | -#include "pxa2xx_template.h" | 106 | @@ -XXX,XX +XXX,XX @@ static void imx_gpt_register_types(void) |
109 | - | 107 | type_register_static(&imx25_gpt_info); |
110 | static const GraphicHwOps pxa2xx_ops = { | 108 | type_register_static(&imx31_gpt_info); |
111 | .invalidate = pxa2xx_invalidate_display, | 109 | type_register_static(&imx6_gpt_info); |
112 | .gfx_update = pxa2xx_update_display, | 110 | + type_register_static(&imx6ul_gpt_info); |
113 | @@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, | 111 | type_register_static(&imx7_gpt_info); |
114 | hwaddr base, qemu_irq irq) | 112 | } |
115 | { | ||
116 | PXA2xxLCDState *s; | ||
117 | - DisplaySurface *surface; | ||
118 | |||
119 | s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState)); | ||
120 | s->invalidated = 1; | ||
121 | @@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, | ||
122 | memory_region_add_subregion(sysmem, base, &s->iomem); | ||
123 | |||
124 | s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s); | ||
125 | - surface = qemu_console_surface(s->con); | ||
126 | - | ||
127 | - switch (surface_bits_per_pixel(surface)) { | ||
128 | - case 0: | ||
129 | - s->dest_width = 0; | ||
130 | - break; | ||
131 | - case 8: | ||
132 | - s->line_fn[0] = pxa2xx_draw_fn_8; | ||
133 | - s->line_fn[1] = pxa2xx_draw_fn_8t; | ||
134 | - s->dest_width = 1; | ||
135 | - break; | ||
136 | - case 15: | ||
137 | - s->line_fn[0] = pxa2xx_draw_fn_15; | ||
138 | - s->line_fn[1] = pxa2xx_draw_fn_15t; | ||
139 | - s->dest_width = 2; | ||
140 | - break; | ||
141 | - case 16: | ||
142 | - s->line_fn[0] = pxa2xx_draw_fn_16; | ||
143 | - s->line_fn[1] = pxa2xx_draw_fn_16t; | ||
144 | - s->dest_width = 2; | ||
145 | - break; | ||
146 | - case 24: | ||
147 | - s->line_fn[0] = pxa2xx_draw_fn_24; | ||
148 | - s->line_fn[1] = pxa2xx_draw_fn_24t; | ||
149 | - s->dest_width = 3; | ||
150 | - break; | ||
151 | - case 32: | ||
152 | - s->line_fn[0] = pxa2xx_draw_fn_32; | ||
153 | - s->line_fn[1] = pxa2xx_draw_fn_32t; | ||
154 | - s->dest_width = 4; | ||
155 | - break; | ||
156 | - default: | ||
157 | - fprintf(stderr, "%s: Bad color depth\n", __func__); | ||
158 | - exit(1); | ||
159 | - } | ||
160 | + s->dest_width = 4; | ||
161 | |||
162 | vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s); | ||
163 | 113 | ||
164 | -- | 114 | -- |
165 | 2.20.1 | 115 | 2.25.1 |
166 | |||
167 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Since b64ee454a4a0, all predicate operations should be | 3 | IRQs were not associated to the various GPIO devices inside i.MX7D. |
4 | using these field macros for predicates. | 4 | This patch brings the i.MX7D on par with i.MX6. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | Message-id: 20210309155305.11301-7-richard.henderson@linaro.org | 7 | Message-id: 20221226101418.415170-1-jcd@tribudubois.net |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/sve_helper.c | 6 +++--- | 11 | include/hw/arm/fsl-imx7.h | 15 +++++++++++++++ |
12 | target/arm/translate-sve.c | 6 +++--- | 12 | hw/arm/fsl-imx7.c | 31 ++++++++++++++++++++++++++++++- |
13 | 2 files changed, 6 insertions(+), 6 deletions(-) | 13 | 2 files changed, 45 insertions(+), 1 deletion(-) |
14 | 14 | ||
15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 15 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/sve_helper.c | 17 | --- a/include/hw/arm/fsl-imx7.h |
18 | +++ b/target/arm/sve_helper.c | 18 | +++ b/include/hw/arm/fsl-imx7.h |
19 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkns)(void *vd, void *vn, void *vg, uint32_t pred_desc) | 19 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
20 | 20 | FSL_IMX7_GPT3_IRQ = 53, | |
21 | uint64_t HELPER(sve_cntp)(void *vn, void *vg, uint32_t pred_desc) | 21 | FSL_IMX7_GPT4_IRQ = 52, |
22 | { | 22 | |
23 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | 23 | + FSL_IMX7_GPIO1_LOW_IRQ = 64, |
24 | - intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2); | 24 | + FSL_IMX7_GPIO1_HIGH_IRQ = 65, |
25 | + intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8); | 25 | + FSL_IMX7_GPIO2_LOW_IRQ = 66, |
26 | + intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); | 26 | + FSL_IMX7_GPIO2_HIGH_IRQ = 67, |
27 | uint64_t *n = vn, *g = vg, sum = 0, mask = pred_esz_masks[esz]; | 27 | + FSL_IMX7_GPIO3_LOW_IRQ = 68, |
28 | intptr_t i; | 28 | + FSL_IMX7_GPIO3_HIGH_IRQ = 69, |
29 | 29 | + FSL_IMX7_GPIO4_LOW_IRQ = 70, | |
30 | - for (i = 0; i < DIV_ROUND_UP(oprsz, 8); ++i) { | 30 | + FSL_IMX7_GPIO4_HIGH_IRQ = 71, |
31 | + for (i = 0; i < words; ++i) { | 31 | + FSL_IMX7_GPIO5_LOW_IRQ = 72, |
32 | uint64_t t = n[i] & g[i] & mask; | 32 | + FSL_IMX7_GPIO5_HIGH_IRQ = 73, |
33 | sum += ctpop64(t); | 33 | + FSL_IMX7_GPIO6_LOW_IRQ = 74, |
34 | + FSL_IMX7_GPIO6_HIGH_IRQ = 75, | ||
35 | + FSL_IMX7_GPIO7_LOW_IRQ = 76, | ||
36 | + FSL_IMX7_GPIO7_HIGH_IRQ = 77, | ||
37 | + | ||
38 | FSL_IMX7_WDOG1_IRQ = 78, | ||
39 | FSL_IMX7_WDOG2_IRQ = 79, | ||
40 | FSL_IMX7_WDOG3_IRQ = 10, | ||
41 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/arm/fsl-imx7.c | ||
44 | +++ b/hw/arm/fsl-imx7.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
46 | FSL_IMX7_GPIO7_ADDR, | ||
47 | }; | ||
48 | |||
49 | + static const int FSL_IMX7_GPIOn_LOW_IRQ[FSL_IMX7_NUM_GPIOS] = { | ||
50 | + FSL_IMX7_GPIO1_LOW_IRQ, | ||
51 | + FSL_IMX7_GPIO2_LOW_IRQ, | ||
52 | + FSL_IMX7_GPIO3_LOW_IRQ, | ||
53 | + FSL_IMX7_GPIO4_LOW_IRQ, | ||
54 | + FSL_IMX7_GPIO5_LOW_IRQ, | ||
55 | + FSL_IMX7_GPIO6_LOW_IRQ, | ||
56 | + FSL_IMX7_GPIO7_LOW_IRQ, | ||
57 | + }; | ||
58 | + | ||
59 | + static const int FSL_IMX7_GPIOn_HIGH_IRQ[FSL_IMX7_NUM_GPIOS] = { | ||
60 | + FSL_IMX7_GPIO1_HIGH_IRQ, | ||
61 | + FSL_IMX7_GPIO2_HIGH_IRQ, | ||
62 | + FSL_IMX7_GPIO3_HIGH_IRQ, | ||
63 | + FSL_IMX7_GPIO4_HIGH_IRQ, | ||
64 | + FSL_IMX7_GPIO5_HIGH_IRQ, | ||
65 | + FSL_IMX7_GPIO6_HIGH_IRQ, | ||
66 | + FSL_IMX7_GPIO7_HIGH_IRQ, | ||
67 | + }; | ||
68 | + | ||
69 | sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &error_abort); | ||
70 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, FSL_IMX7_GPIOn_ADDR[i]); | ||
71 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, | ||
72 | + FSL_IMX7_GPIOn_ADDR[i]); | ||
73 | + | ||
74 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, | ||
75 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
76 | + FSL_IMX7_GPIOn_LOW_IRQ[i])); | ||
77 | + | ||
78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1, | ||
79 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
80 | + FSL_IMX7_GPIOn_HIGH_IRQ[i])); | ||
34 | } | 81 | } |
35 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 82 | |
36 | index XXXXXXX..XXXXXXX 100644 | 83 | /* |
37 | --- a/target/arm/translate-sve.c | ||
38 | +++ b/target/arm/translate-sve.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void do_cntp(DisasContext *s, TCGv_i64 val, int esz, int pn, int pg) | ||
40 | } else { | ||
41 | TCGv_ptr t_pn = tcg_temp_new_ptr(); | ||
42 | TCGv_ptr t_pg = tcg_temp_new_ptr(); | ||
43 | - unsigned desc; | ||
44 | + unsigned desc = 0; | ||
45 | TCGv_i32 t_desc; | ||
46 | |||
47 | - desc = psz - 2; | ||
48 | - desc = deposit32(desc, SIMD_DATA_SHIFT, 2, esz); | ||
49 | + desc = FIELD_DP32(desc, PREDDESC, OPRSZ, psz); | ||
50 | + desc = FIELD_DP32(desc, PREDDESC, ESZ, esz); | ||
51 | |||
52 | tcg_gen_addi_ptr(t_pn, cpu_env, pred_full_reg_offset(s, pn)); | ||
53 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | ||
54 | -- | 84 | -- |
55 | 2.20.1 | 85 | 2.25.1 |
56 | |||
57 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Stephen Longfield <slongfield@google.com> |
---|---|---|---|
2 | 2 | ||
3 | If the SSECounter link is absent, we set an error message | 3 | Size is used at lines 1088/1188 for the loop, which reads the last 4 |
4 | in sse_timer_realize() but forgot to propagate this error. | 4 | bytes from the crc_ptr so it does need to get increased, however it |
5 | Add the missing 'return'. | 5 | shouldn't be increased before the buffer is passed to CRC computation, |
6 | or the crc32 function will access uninitialized memory. | ||
6 | 7 | ||
7 | Fixes: CID 1450755 (Null pointer dereferences) | 8 | This was pointed out to me by clg@kaod.org during the code review of |
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | a similar patch to hw/net/ftgmac100.c |
9 | Message-id: 20210312001845.1562670-1-f4bug@amsat.org | 10 | |
11 | Change-Id: Ib0464303b191af1e28abeb2f5105eb25aadb5e9b | ||
12 | Signed-off-by: Stephen Longfield <slongfield@google.com> | ||
13 | Reviewed-by: Patrick Venture <venture@google.com> | ||
14 | Message-id: 20221221183202.3788132-1-slongfield@google.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 17 | --- |
13 | hw/timer/sse-timer.c | 1 + | 18 | hw/net/imx_fec.c | 8 ++++---- |
14 | 1 file changed, 1 insertion(+) | 19 | 1 file changed, 4 insertions(+), 4 deletions(-) |
15 | 20 | ||
16 | diff --git a/hw/timer/sse-timer.c b/hw/timer/sse-timer.c | 21 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c |
17 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/timer/sse-timer.c | 23 | --- a/hw/net/imx_fec.c |
19 | +++ b/hw/timer/sse-timer.c | 24 | +++ b/hw/net/imx_fec.c |
20 | @@ -XXX,XX +XXX,XX @@ static void sse_timer_realize(DeviceState *dev, Error **errp) | 25 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, |
21 | 26 | return 0; | |
22 | if (!s->counter) { | ||
23 | error_setg(errp, "counter property was not set"); | ||
24 | + return; | ||
25 | } | 27 | } |
26 | 28 | ||
27 | s->counter_notifier.notify = sse_timer_counter_callback; | 29 | - /* 4 bytes for the CRC. */ |
30 | - size += 4; | ||
31 | crc = cpu_to_be32(crc32(~0, buf, size)); | ||
32 | + /* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */ | ||
33 | + size += 4; | ||
34 | crc_ptr = (uint8_t *) &crc; | ||
35 | |||
36 | /* Huge frames are truncated. */ | ||
37 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | - /* 4 bytes for the CRC. */ | ||
42 | - size += 4; | ||
43 | crc = cpu_to_be32(crc32(~0, buf, size)); | ||
44 | + /* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */ | ||
45 | + size += 4; | ||
46 | crc_ptr = (uint8_t *) &crc; | ||
47 | |||
48 | if (shift16) { | ||
28 | -- | 49 | -- |
29 | 2.20.1 | 50 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Since the dest_width is now always 4 because the output surface is | ||
2 | 32bpp, we can replace the dest_width state field with a constant. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
6 | Message-id: 20210211141515.8755-6-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/display/pxa2xx_lcd.c | 20 +++++++++++--------- | ||
9 | 1 file changed, 11 insertions(+), 9 deletions(-) | ||
10 | |||
11 | diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/display/pxa2xx_lcd.c | ||
14 | +++ b/hw/display/pxa2xx_lcd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED { | ||
16 | #define LDCMD_SOFINT (1 << 22) | ||
17 | #define LDCMD_PAL (1 << 26) | ||
18 | |||
19 | +/* Size of a pixel in the QEMU UI output surface, in bytes */ | ||
20 | +#define DEST_PIXEL_WIDTH 4 | ||
21 | + | ||
22 | #define BITS 32 | ||
23 | #include "pxa2xx_template.h" | ||
24 | |||
25 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s, | ||
26 | else if (s->bpp > pxa_lcdc_8bpp) | ||
27 | src_width *= 2; | ||
28 | |||
29 | - dest_width = s->xres * s->dest_width; | ||
30 | + dest_width = s->xres * DEST_PIXEL_WIDTH; | ||
31 | *miny = 0; | ||
32 | if (s->invalidated) { | ||
33 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
34 | addr, s->yres, src_width); | ||
35 | } | ||
36 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | ||
37 | - src_width, dest_width, s->dest_width, | ||
38 | + src_width, dest_width, DEST_PIXEL_WIDTH, | ||
39 | s->invalidated, | ||
40 | fn, s->dma_ch[0].palette, miny, maxy); | ||
41 | } | ||
42 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, | ||
43 | else if (s->bpp > pxa_lcdc_8bpp) | ||
44 | src_width *= 2; | ||
45 | |||
46 | - dest_width = s->yres * s->dest_width; | ||
47 | + dest_width = s->yres * DEST_PIXEL_WIDTH; | ||
48 | *miny = 0; | ||
49 | if (s->invalidated) { | ||
50 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
51 | addr, s->yres, src_width); | ||
52 | } | ||
53 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | ||
54 | - src_width, s->dest_width, -dest_width, | ||
55 | + src_width, DEST_PIXEL_WIDTH, -dest_width, | ||
56 | s->invalidated, | ||
57 | fn, s->dma_ch[0].palette, | ||
58 | miny, maxy); | ||
59 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s, | ||
60 | src_width *= 2; | ||
61 | } | ||
62 | |||
63 | - dest_width = s->xres * s->dest_width; | ||
64 | + dest_width = s->xres * DEST_PIXEL_WIDTH; | ||
65 | *miny = 0; | ||
66 | if (s->invalidated) { | ||
67 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
68 | addr, s->yres, src_width); | ||
69 | } | ||
70 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | ||
71 | - src_width, -dest_width, -s->dest_width, | ||
72 | + src_width, -dest_width, -DEST_PIXEL_WIDTH, | ||
73 | s->invalidated, | ||
74 | fn, s->dma_ch[0].palette, miny, maxy); | ||
75 | } | ||
76 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, | ||
77 | src_width *= 2; | ||
78 | } | ||
79 | |||
80 | - dest_width = s->yres * s->dest_width; | ||
81 | + dest_width = s->yres * DEST_PIXEL_WIDTH; | ||
82 | *miny = 0; | ||
83 | if (s->invalidated) { | ||
84 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
85 | addr, s->yres, src_width); | ||
86 | } | ||
87 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | ||
88 | - src_width, -s->dest_width, dest_width, | ||
89 | + src_width, -DEST_PIXEL_WIDTH, dest_width, | ||
90 | s->invalidated, | ||
91 | fn, s->dma_ch[0].palette, | ||
92 | miny, maxy); | ||
93 | @@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, | ||
94 | memory_region_add_subregion(sysmem, base, &s->iomem); | ||
95 | |||
96 | s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s); | ||
97 | - s->dest_width = 4; | ||
98 | |||
99 | vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s); | ||
100 | |||
101 | -- | ||
102 | 2.20.1 | ||
103 | |||
104 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We're about to move code from the template header into pxa2xx_lcd.c. | ||
2 | Before doing that, make coding style fixes so checkpatch doesn't | ||
3 | complain about the patch which moves the code. This commit fixes | ||
4 | missing braces in the SKIP_PIXEL() macro definition and in if() | ||
5 | statements. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
9 | Message-id: 20210211141515.8755-8-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/display/pxa2xx_template.h | 47 +++++++++++++++++++++--------------- | ||
12 | 1 file changed, 28 insertions(+), 19 deletions(-) | ||
13 | |||
14 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/display/pxa2xx_template.h | ||
17 | +++ b/hw/display/pxa2xx_template.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | * Framebuffer format conversion routines. | ||
20 | */ | ||
21 | |||
22 | -# define SKIP_PIXEL(to) to += deststep | ||
23 | +# define SKIP_PIXEL(to) do { to += deststep; } while (0) | ||
24 | # define COPY_PIXEL(to, from) \ | ||
25 | do { \ | ||
26 | *(uint32_t *) to = from; \ | ||
27 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque, | ||
28 | data >>= 5; | ||
29 | r = (data & 0x1f) << 3; | ||
30 | data >>= 5; | ||
31 | - if (data & 1) | ||
32 | + if (data & 1) { | ||
33 | SKIP_PIXEL(dest); | ||
34 | - else | ||
35 | + } else { | ||
36 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
37 | + } | ||
38 | data >>= 1; | ||
39 | b = (data & 0x1f) << 3; | ||
40 | data >>= 5; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque, | ||
42 | data >>= 5; | ||
43 | r = (data & 0x1f) << 3; | ||
44 | data >>= 5; | ||
45 | - if (data & 1) | ||
46 | + if (data & 1) { | ||
47 | SKIP_PIXEL(dest); | ||
48 | - else | ||
49 | + } else { | ||
50 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
51 | + } | ||
52 | width -= 2; | ||
53 | src += 4; | ||
54 | } | ||
55 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19(void *opaque, | ||
56 | data >>= 6; | ||
57 | r = (data & 0x3f) << 2; | ||
58 | data >>= 6; | ||
59 | - if (data & 1) | ||
60 | + if (data & 1) { | ||
61 | SKIP_PIXEL(dest); | ||
62 | - else | ||
63 | + } else { | ||
64 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
65 | + } | ||
66 | width -= 1; | ||
67 | src += 4; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, | ||
70 | data[0] >>= 6; | ||
71 | r = (data[0] & 0x3f) << 2; | ||
72 | data[0] >>= 6; | ||
73 | - if (data[0] & 1) | ||
74 | + if (data[0] & 1) { | ||
75 | SKIP_PIXEL(dest); | ||
76 | - else | ||
77 | + } else { | ||
78 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
79 | + } | ||
80 | data[0] >>= 6; | ||
81 | b = (data[0] & 0x3f) << 2; | ||
82 | data[0] >>= 6; | ||
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, | ||
84 | data[1] >>= 4; | ||
85 | r = (data[1] & 0x3f) << 2; | ||
86 | data[1] >>= 6; | ||
87 | - if (data[1] & 1) | ||
88 | + if (data[1] & 1) { | ||
89 | SKIP_PIXEL(dest); | ||
90 | - else | ||
91 | + } else { | ||
92 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
93 | + } | ||
94 | data[1] >>= 6; | ||
95 | b = (data[1] & 0x3f) << 2; | ||
96 | data[1] >>= 6; | ||
97 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, | ||
98 | data[1] >>= 6; | ||
99 | r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
100 | data[2] >>= 2; | ||
101 | - if (data[2] & 1) | ||
102 | + if (data[2] & 1) { | ||
103 | SKIP_PIXEL(dest); | ||
104 | - else | ||
105 | + } else { | ||
106 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
107 | + } | ||
108 | data[2] >>= 6; | ||
109 | b = (data[2] & 0x3f) << 2; | ||
110 | data[2] >>= 6; | ||
111 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, | ||
112 | data[2] >>= 6; | ||
113 | r = data[2] << 2; | ||
114 | data[2] >>= 6; | ||
115 | - if (data[2] & 1) | ||
116 | + if (data[2] & 1) { | ||
117 | SKIP_PIXEL(dest); | ||
118 | - else | ||
119 | + } else { | ||
120 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
121 | + } | ||
122 | width -= 4; | ||
123 | } | ||
124 | } | ||
125 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24t(void *opaque, | ||
126 | data >>= 8; | ||
127 | r = data & 0xff; | ||
128 | data >>= 8; | ||
129 | - if (data & 1) | ||
130 | + if (data & 1) { | ||
131 | SKIP_PIXEL(dest); | ||
132 | - else | ||
133 | + } else { | ||
134 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
135 | + } | ||
136 | width -= 1; | ||
137 | src += 4; | ||
138 | } | ||
139 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line25(void *opaque, | ||
140 | data >>= 8; | ||
141 | r = data & 0xff; | ||
142 | data >>= 8; | ||
143 | - if (data & 1) | ||
144 | + if (data & 1) { | ||
145 | SKIP_PIXEL(dest); | ||
146 | - else | ||
147 | + } else { | ||
148 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
149 | + } | ||
150 | width -= 1; | ||
151 | src += 4; | ||
152 | } | ||
153 | -- | ||
154 | 2.20.1 | ||
155 | |||
156 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The template header is now included only once; just inline its contents | ||
2 | in hw/display/pxa2xx_lcd.c. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
6 | Message-id: 20210211141515.8755-10-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/display/pxa2xx_template.h | 434 ----------------------------------- | ||
9 | hw/display/pxa2xx_lcd.c | 427 +++++++++++++++++++++++++++++++++- | ||
10 | 2 files changed, 425 insertions(+), 436 deletions(-) | ||
11 | delete mode 100644 hw/display/pxa2xx_template.h | ||
12 | |||
13 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h | ||
14 | deleted file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- a/hw/display/pxa2xx_template.h | ||
17 | +++ /dev/null | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | -/* | ||
20 | - * Intel XScale PXA255/270 LCDC emulation. | ||
21 | - * | ||
22 | - * Copyright (c) 2006 Openedhand Ltd. | ||
23 | - * Written by Andrzej Zaborowski <balrog@zabor.org> | ||
24 | - * | ||
25 | - * This code is licensed under the GPLv2. | ||
26 | - * | ||
27 | - * Framebuffer format conversion routines. | ||
28 | - */ | ||
29 | - | ||
30 | -# define SKIP_PIXEL(to) do { to += deststep; } while (0) | ||
31 | -# define COPY_PIXEL(to, from) \ | ||
32 | - do { \ | ||
33 | - *(uint32_t *) to = from; \ | ||
34 | - SKIP_PIXEL(to); \ | ||
35 | - } while (0) | ||
36 | - | ||
37 | -#ifdef HOST_WORDS_BIGENDIAN | ||
38 | -# define SWAP_WORDS 1 | ||
39 | -#endif | ||
40 | - | ||
41 | -#define FN_2(x) FN(x + 1) FN(x) | ||
42 | -#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
43 | - | ||
44 | -static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src, | ||
45 | - int width, int deststep) | ||
46 | -{ | ||
47 | - uint32_t *palette = opaque; | ||
48 | - uint32_t data; | ||
49 | - while (width > 0) { | ||
50 | - data = *(uint32_t *) src; | ||
51 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
52 | -#ifdef SWAP_WORDS | ||
53 | - FN_4(12) | ||
54 | - FN_4(8) | ||
55 | - FN_4(4) | ||
56 | - FN_4(0) | ||
57 | -#else | ||
58 | - FN_4(0) | ||
59 | - FN_4(4) | ||
60 | - FN_4(8) | ||
61 | - FN_4(12) | ||
62 | -#endif | ||
63 | -#undef FN | ||
64 | - width -= 16; | ||
65 | - src += 4; | ||
66 | - } | ||
67 | -} | ||
68 | - | ||
69 | -static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src, | ||
70 | - int width, int deststep) | ||
71 | -{ | ||
72 | - uint32_t *palette = opaque; | ||
73 | - uint32_t data; | ||
74 | - while (width > 0) { | ||
75 | - data = *(uint32_t *) src; | ||
76 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | ||
77 | -#ifdef SWAP_WORDS | ||
78 | - FN_2(6) | ||
79 | - FN_2(4) | ||
80 | - FN_2(2) | ||
81 | - FN_2(0) | ||
82 | -#else | ||
83 | - FN_2(0) | ||
84 | - FN_2(2) | ||
85 | - FN_2(4) | ||
86 | - FN_2(6) | ||
87 | -#endif | ||
88 | -#undef FN | ||
89 | - width -= 8; | ||
90 | - src += 4; | ||
91 | - } | ||
92 | -} | ||
93 | - | ||
94 | -static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src, | ||
95 | - int width, int deststep) | ||
96 | -{ | ||
97 | - uint32_t *palette = opaque; | ||
98 | - uint32_t data; | ||
99 | - while (width > 0) { | ||
100 | - data = *(uint32_t *) src; | ||
101 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
102 | -#ifdef SWAP_WORDS | ||
103 | - FN(24) | ||
104 | - FN(16) | ||
105 | - FN(8) | ||
106 | - FN(0) | ||
107 | -#else | ||
108 | - FN(0) | ||
109 | - FN(8) | ||
110 | - FN(16) | ||
111 | - FN(24) | ||
112 | -#endif | ||
113 | -#undef FN | ||
114 | - width -= 4; | ||
115 | - src += 4; | ||
116 | - } | ||
117 | -} | ||
118 | - | ||
119 | -static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src, | ||
120 | - int width, int deststep) | ||
121 | -{ | ||
122 | - uint32_t data; | ||
123 | - unsigned int r, g, b; | ||
124 | - while (width > 0) { | ||
125 | - data = *(uint32_t *) src; | ||
126 | -#ifdef SWAP_WORDS | ||
127 | - data = bswap32(data); | ||
128 | -#endif | ||
129 | - b = (data & 0x1f) << 3; | ||
130 | - data >>= 5; | ||
131 | - g = (data & 0x3f) << 2; | ||
132 | - data >>= 6; | ||
133 | - r = (data & 0x1f) << 3; | ||
134 | - data >>= 5; | ||
135 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
136 | - b = (data & 0x1f) << 3; | ||
137 | - data >>= 5; | ||
138 | - g = (data & 0x3f) << 2; | ||
139 | - data >>= 6; | ||
140 | - r = (data & 0x1f) << 3; | ||
141 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
142 | - width -= 2; | ||
143 | - src += 4; | ||
144 | - } | ||
145 | -} | ||
146 | - | ||
147 | -static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
148 | - int width, int deststep) | ||
149 | -{ | ||
150 | - uint32_t data; | ||
151 | - unsigned int r, g, b; | ||
152 | - while (width > 0) { | ||
153 | - data = *(uint32_t *) src; | ||
154 | -#ifdef SWAP_WORDS | ||
155 | - data = bswap32(data); | ||
156 | -#endif | ||
157 | - b = (data & 0x1f) << 3; | ||
158 | - data >>= 5; | ||
159 | - g = (data & 0x1f) << 3; | ||
160 | - data >>= 5; | ||
161 | - r = (data & 0x1f) << 3; | ||
162 | - data >>= 5; | ||
163 | - if (data & 1) { | ||
164 | - SKIP_PIXEL(dest); | ||
165 | - } else { | ||
166 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
167 | - } | ||
168 | - data >>= 1; | ||
169 | - b = (data & 0x1f) << 3; | ||
170 | - data >>= 5; | ||
171 | - g = (data & 0x1f) << 3; | ||
172 | - data >>= 5; | ||
173 | - r = (data & 0x1f) << 3; | ||
174 | - data >>= 5; | ||
175 | - if (data & 1) { | ||
176 | - SKIP_PIXEL(dest); | ||
177 | - } else { | ||
178 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
179 | - } | ||
180 | - width -= 2; | ||
181 | - src += 4; | ||
182 | - } | ||
183 | -} | ||
184 | - | ||
185 | -static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src, | ||
186 | - int width, int deststep) | ||
187 | -{ | ||
188 | - uint32_t data; | ||
189 | - unsigned int r, g, b; | ||
190 | - while (width > 0) { | ||
191 | - data = *(uint32_t *) src; | ||
192 | -#ifdef SWAP_WORDS | ||
193 | - data = bswap32(data); | ||
194 | -#endif | ||
195 | - b = (data & 0x3f) << 2; | ||
196 | - data >>= 6; | ||
197 | - g = (data & 0x3f) << 2; | ||
198 | - data >>= 6; | ||
199 | - r = (data & 0x3f) << 2; | ||
200 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
201 | - width -= 1; | ||
202 | - src += 4; | ||
203 | - } | ||
204 | -} | ||
205 | - | ||
206 | -/* The wicked packed format */ | ||
207 | -static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
208 | - int width, int deststep) | ||
209 | -{ | ||
210 | - uint32_t data[3]; | ||
211 | - unsigned int r, g, b; | ||
212 | - while (width > 0) { | ||
213 | - data[0] = *(uint32_t *) src; | ||
214 | - src += 4; | ||
215 | - data[1] = *(uint32_t *) src; | ||
216 | - src += 4; | ||
217 | - data[2] = *(uint32_t *) src; | ||
218 | - src += 4; | ||
219 | -#ifdef SWAP_WORDS | ||
220 | - data[0] = bswap32(data[0]); | ||
221 | - data[1] = bswap32(data[1]); | ||
222 | - data[2] = bswap32(data[2]); | ||
223 | -#endif | ||
224 | - b = (data[0] & 0x3f) << 2; | ||
225 | - data[0] >>= 6; | ||
226 | - g = (data[0] & 0x3f) << 2; | ||
227 | - data[0] >>= 6; | ||
228 | - r = (data[0] & 0x3f) << 2; | ||
229 | - data[0] >>= 12; | ||
230 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
231 | - b = (data[0] & 0x3f) << 2; | ||
232 | - data[0] >>= 6; | ||
233 | - g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
234 | - data[1] >>= 4; | ||
235 | - r = (data[1] & 0x3f) << 2; | ||
236 | - data[1] >>= 12; | ||
237 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
238 | - b = (data[1] & 0x3f) << 2; | ||
239 | - data[1] >>= 6; | ||
240 | - g = (data[1] & 0x3f) << 2; | ||
241 | - data[1] >>= 6; | ||
242 | - r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
243 | - data[2] >>= 8; | ||
244 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
245 | - b = (data[2] & 0x3f) << 2; | ||
246 | - data[2] >>= 6; | ||
247 | - g = (data[2] & 0x3f) << 2; | ||
248 | - data[2] >>= 6; | ||
249 | - r = data[2] << 2; | ||
250 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
251 | - width -= 4; | ||
252 | - } | ||
253 | -} | ||
254 | - | ||
255 | -static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src, | ||
256 | - int width, int deststep) | ||
257 | -{ | ||
258 | - uint32_t data; | ||
259 | - unsigned int r, g, b; | ||
260 | - while (width > 0) { | ||
261 | - data = *(uint32_t *) src; | ||
262 | -#ifdef SWAP_WORDS | ||
263 | - data = bswap32(data); | ||
264 | -#endif | ||
265 | - b = (data & 0x3f) << 2; | ||
266 | - data >>= 6; | ||
267 | - g = (data & 0x3f) << 2; | ||
268 | - data >>= 6; | ||
269 | - r = (data & 0x3f) << 2; | ||
270 | - data >>= 6; | ||
271 | - if (data & 1) { | ||
272 | - SKIP_PIXEL(dest); | ||
273 | - } else { | ||
274 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
275 | - } | ||
276 | - width -= 1; | ||
277 | - src += 4; | ||
278 | - } | ||
279 | -} | ||
280 | - | ||
281 | -/* The wicked packed format */ | ||
282 | -static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
283 | - int width, int deststep) | ||
284 | -{ | ||
285 | - uint32_t data[3]; | ||
286 | - unsigned int r, g, b; | ||
287 | - while (width > 0) { | ||
288 | - data[0] = *(uint32_t *) src; | ||
289 | - src += 4; | ||
290 | - data[1] = *(uint32_t *) src; | ||
291 | - src += 4; | ||
292 | - data[2] = *(uint32_t *) src; | ||
293 | - src += 4; | ||
294 | -# ifdef SWAP_WORDS | ||
295 | - data[0] = bswap32(data[0]); | ||
296 | - data[1] = bswap32(data[1]); | ||
297 | - data[2] = bswap32(data[2]); | ||
298 | -# endif | ||
299 | - b = (data[0] & 0x3f) << 2; | ||
300 | - data[0] >>= 6; | ||
301 | - g = (data[0] & 0x3f) << 2; | ||
302 | - data[0] >>= 6; | ||
303 | - r = (data[0] & 0x3f) << 2; | ||
304 | - data[0] >>= 6; | ||
305 | - if (data[0] & 1) { | ||
306 | - SKIP_PIXEL(dest); | ||
307 | - } else { | ||
308 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
309 | - } | ||
310 | - data[0] >>= 6; | ||
311 | - b = (data[0] & 0x3f) << 2; | ||
312 | - data[0] >>= 6; | ||
313 | - g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
314 | - data[1] >>= 4; | ||
315 | - r = (data[1] & 0x3f) << 2; | ||
316 | - data[1] >>= 6; | ||
317 | - if (data[1] & 1) { | ||
318 | - SKIP_PIXEL(dest); | ||
319 | - } else { | ||
320 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
321 | - } | ||
322 | - data[1] >>= 6; | ||
323 | - b = (data[1] & 0x3f) << 2; | ||
324 | - data[1] >>= 6; | ||
325 | - g = (data[1] & 0x3f) << 2; | ||
326 | - data[1] >>= 6; | ||
327 | - r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
328 | - data[2] >>= 2; | ||
329 | - if (data[2] & 1) { | ||
330 | - SKIP_PIXEL(dest); | ||
331 | - } else { | ||
332 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
333 | - } | ||
334 | - data[2] >>= 6; | ||
335 | - b = (data[2] & 0x3f) << 2; | ||
336 | - data[2] >>= 6; | ||
337 | - g = (data[2] & 0x3f) << 2; | ||
338 | - data[2] >>= 6; | ||
339 | - r = data[2] << 2; | ||
340 | - data[2] >>= 6; | ||
341 | - if (data[2] & 1) { | ||
342 | - SKIP_PIXEL(dest); | ||
343 | - } else { | ||
344 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
345 | - } | ||
346 | - width -= 4; | ||
347 | - } | ||
348 | -} | ||
349 | - | ||
350 | -static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src, | ||
351 | - int width, int deststep) | ||
352 | -{ | ||
353 | - uint32_t data; | ||
354 | - unsigned int r, g, b; | ||
355 | - while (width > 0) { | ||
356 | - data = *(uint32_t *) src; | ||
357 | -#ifdef SWAP_WORDS | ||
358 | - data = bswap32(data); | ||
359 | -#endif | ||
360 | - b = data & 0xff; | ||
361 | - data >>= 8; | ||
362 | - g = data & 0xff; | ||
363 | - data >>= 8; | ||
364 | - r = data & 0xff; | ||
365 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
366 | - width -= 1; | ||
367 | - src += 4; | ||
368 | - } | ||
369 | -} | ||
370 | - | ||
371 | -static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
372 | - int width, int deststep) | ||
373 | -{ | ||
374 | - uint32_t data; | ||
375 | - unsigned int r, g, b; | ||
376 | - while (width > 0) { | ||
377 | - data = *(uint32_t *) src; | ||
378 | -#ifdef SWAP_WORDS | ||
379 | - data = bswap32(data); | ||
380 | -#endif | ||
381 | - b = (data & 0x7f) << 1; | ||
382 | - data >>= 7; | ||
383 | - g = data & 0xff; | ||
384 | - data >>= 8; | ||
385 | - r = data & 0xff; | ||
386 | - data >>= 8; | ||
387 | - if (data & 1) { | ||
388 | - SKIP_PIXEL(dest); | ||
389 | - } else { | ||
390 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
391 | - } | ||
392 | - width -= 1; | ||
393 | - src += 4; | ||
394 | - } | ||
395 | -} | ||
396 | - | ||
397 | -static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src, | ||
398 | - int width, int deststep) | ||
399 | -{ | ||
400 | - uint32_t data; | ||
401 | - unsigned int r, g, b; | ||
402 | - while (width > 0) { | ||
403 | - data = *(uint32_t *) src; | ||
404 | -#ifdef SWAP_WORDS | ||
405 | - data = bswap32(data); | ||
406 | -#endif | ||
407 | - b = data & 0xff; | ||
408 | - data >>= 8; | ||
409 | - g = data & 0xff; | ||
410 | - data >>= 8; | ||
411 | - r = data & 0xff; | ||
412 | - data >>= 8; | ||
413 | - if (data & 1) { | ||
414 | - SKIP_PIXEL(dest); | ||
415 | - } else { | ||
416 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
417 | - } | ||
418 | - width -= 1; | ||
419 | - src += 4; | ||
420 | - } | ||
421 | -} | ||
422 | - | ||
423 | -/* Overlay planes disabled, no transparency */ | ||
424 | -static drawfn pxa2xx_draw_fn_32[16] = { | ||
425 | - [0 ... 0xf] = NULL, | ||
426 | - [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
427 | - [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
428 | - [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
429 | - [pxa_lcdc_16bpp] = pxa2xx_draw_line16, | ||
430 | - [pxa_lcdc_18bpp] = pxa2xx_draw_line18, | ||
431 | - [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p, | ||
432 | - [pxa_lcdc_24bpp] = pxa2xx_draw_line24, | ||
433 | -}; | ||
434 | - | ||
435 | -/* Overlay planes enabled, transparency used */ | ||
436 | -static drawfn pxa2xx_draw_fn_32t[16] = { | ||
437 | - [0 ... 0xf] = NULL, | ||
438 | - [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
439 | - [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
440 | - [pxa_lcdc_16bpp] = pxa2xx_draw_line16t, | ||
441 | - [pxa_lcdc_19bpp] = pxa2xx_draw_line19, | ||
442 | - [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p, | ||
443 | - [pxa_lcdc_24bpp] = pxa2xx_draw_line24t, | ||
444 | - [pxa_lcdc_25bpp] = pxa2xx_draw_line25, | ||
445 | -}; | ||
446 | - | ||
447 | -#undef COPY_PIXEL | ||
448 | -#undef SKIP_PIXEL | ||
449 | - | ||
450 | -#ifdef SWAP_WORDS | ||
451 | -# undef SWAP_WORDS | ||
452 | -#endif | ||
453 | diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c | ||
454 | index XXXXXXX..XXXXXXX 100644 | ||
455 | --- a/hw/display/pxa2xx_lcd.c | ||
456 | +++ b/hw/display/pxa2xx_lcd.c | ||
457 | @@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED { | ||
458 | /* Size of a pixel in the QEMU UI output surface, in bytes */ | ||
459 | #define DEST_PIXEL_WIDTH 4 | ||
460 | |||
461 | -#define BITS 32 | ||
462 | -#include "pxa2xx_template.h" | ||
463 | +/* Line drawing code to handle the various possible guest pixel formats */ | ||
464 | + | ||
465 | +# define SKIP_PIXEL(to) do { to += deststep; } while (0) | ||
466 | +# define COPY_PIXEL(to, from) \ | ||
467 | + do { \ | ||
468 | + *(uint32_t *) to = from; \ | ||
469 | + SKIP_PIXEL(to); \ | ||
470 | + } while (0) | ||
471 | + | ||
472 | +#ifdef HOST_WORDS_BIGENDIAN | ||
473 | +# define SWAP_WORDS 1 | ||
474 | +#endif | ||
475 | + | ||
476 | +#define FN_2(x) FN(x + 1) FN(x) | ||
477 | +#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
478 | + | ||
479 | +static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src, | ||
480 | + int width, int deststep) | ||
481 | +{ | ||
482 | + uint32_t *palette = opaque; | ||
483 | + uint32_t data; | ||
484 | + while (width > 0) { | ||
485 | + data = *(uint32_t *) src; | ||
486 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
487 | +#ifdef SWAP_WORDS | ||
488 | + FN_4(12) | ||
489 | + FN_4(8) | ||
490 | + FN_4(4) | ||
491 | + FN_4(0) | ||
492 | +#else | ||
493 | + FN_4(0) | ||
494 | + FN_4(4) | ||
495 | + FN_4(8) | ||
496 | + FN_4(12) | ||
497 | +#endif | ||
498 | +#undef FN | ||
499 | + width -= 16; | ||
500 | + src += 4; | ||
501 | + } | ||
502 | +} | ||
503 | + | ||
504 | +static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src, | ||
505 | + int width, int deststep) | ||
506 | +{ | ||
507 | + uint32_t *palette = opaque; | ||
508 | + uint32_t data; | ||
509 | + while (width > 0) { | ||
510 | + data = *(uint32_t *) src; | ||
511 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | ||
512 | +#ifdef SWAP_WORDS | ||
513 | + FN_2(6) | ||
514 | + FN_2(4) | ||
515 | + FN_2(2) | ||
516 | + FN_2(0) | ||
517 | +#else | ||
518 | + FN_2(0) | ||
519 | + FN_2(2) | ||
520 | + FN_2(4) | ||
521 | + FN_2(6) | ||
522 | +#endif | ||
523 | +#undef FN | ||
524 | + width -= 8; | ||
525 | + src += 4; | ||
526 | + } | ||
527 | +} | ||
528 | + | ||
529 | +static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src, | ||
530 | + int width, int deststep) | ||
531 | +{ | ||
532 | + uint32_t *palette = opaque; | ||
533 | + uint32_t data; | ||
534 | + while (width > 0) { | ||
535 | + data = *(uint32_t *) src; | ||
536 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
537 | +#ifdef SWAP_WORDS | ||
538 | + FN(24) | ||
539 | + FN(16) | ||
540 | + FN(8) | ||
541 | + FN(0) | ||
542 | +#else | ||
543 | + FN(0) | ||
544 | + FN(8) | ||
545 | + FN(16) | ||
546 | + FN(24) | ||
547 | +#endif | ||
548 | +#undef FN | ||
549 | + width -= 4; | ||
550 | + src += 4; | ||
551 | + } | ||
552 | +} | ||
553 | + | ||
554 | +static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src, | ||
555 | + int width, int deststep) | ||
556 | +{ | ||
557 | + uint32_t data; | ||
558 | + unsigned int r, g, b; | ||
559 | + while (width > 0) { | ||
560 | + data = *(uint32_t *) src; | ||
561 | +#ifdef SWAP_WORDS | ||
562 | + data = bswap32(data); | ||
563 | +#endif | ||
564 | + b = (data & 0x1f) << 3; | ||
565 | + data >>= 5; | ||
566 | + g = (data & 0x3f) << 2; | ||
567 | + data >>= 6; | ||
568 | + r = (data & 0x1f) << 3; | ||
569 | + data >>= 5; | ||
570 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
571 | + b = (data & 0x1f) << 3; | ||
572 | + data >>= 5; | ||
573 | + g = (data & 0x3f) << 2; | ||
574 | + data >>= 6; | ||
575 | + r = (data & 0x1f) << 3; | ||
576 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
577 | + width -= 2; | ||
578 | + src += 4; | ||
579 | + } | ||
580 | +} | ||
581 | + | ||
582 | +static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
583 | + int width, int deststep) | ||
584 | +{ | ||
585 | + uint32_t data; | ||
586 | + unsigned int r, g, b; | ||
587 | + while (width > 0) { | ||
588 | + data = *(uint32_t *) src; | ||
589 | +#ifdef SWAP_WORDS | ||
590 | + data = bswap32(data); | ||
591 | +#endif | ||
592 | + b = (data & 0x1f) << 3; | ||
593 | + data >>= 5; | ||
594 | + g = (data & 0x1f) << 3; | ||
595 | + data >>= 5; | ||
596 | + r = (data & 0x1f) << 3; | ||
597 | + data >>= 5; | ||
598 | + if (data & 1) { | ||
599 | + SKIP_PIXEL(dest); | ||
600 | + } else { | ||
601 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
602 | + } | ||
603 | + data >>= 1; | ||
604 | + b = (data & 0x1f) << 3; | ||
605 | + data >>= 5; | ||
606 | + g = (data & 0x1f) << 3; | ||
607 | + data >>= 5; | ||
608 | + r = (data & 0x1f) << 3; | ||
609 | + data >>= 5; | ||
610 | + if (data & 1) { | ||
611 | + SKIP_PIXEL(dest); | ||
612 | + } else { | ||
613 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
614 | + } | ||
615 | + width -= 2; | ||
616 | + src += 4; | ||
617 | + } | ||
618 | +} | ||
619 | + | ||
620 | +static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src, | ||
621 | + int width, int deststep) | ||
622 | +{ | ||
623 | + uint32_t data; | ||
624 | + unsigned int r, g, b; | ||
625 | + while (width > 0) { | ||
626 | + data = *(uint32_t *) src; | ||
627 | +#ifdef SWAP_WORDS | ||
628 | + data = bswap32(data); | ||
629 | +#endif | ||
630 | + b = (data & 0x3f) << 2; | ||
631 | + data >>= 6; | ||
632 | + g = (data & 0x3f) << 2; | ||
633 | + data >>= 6; | ||
634 | + r = (data & 0x3f) << 2; | ||
635 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
636 | + width -= 1; | ||
637 | + src += 4; | ||
638 | + } | ||
639 | +} | ||
640 | + | ||
641 | +/* The wicked packed format */ | ||
642 | +static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
643 | + int width, int deststep) | ||
644 | +{ | ||
645 | + uint32_t data[3]; | ||
646 | + unsigned int r, g, b; | ||
647 | + while (width > 0) { | ||
648 | + data[0] = *(uint32_t *) src; | ||
649 | + src += 4; | ||
650 | + data[1] = *(uint32_t *) src; | ||
651 | + src += 4; | ||
652 | + data[2] = *(uint32_t *) src; | ||
653 | + src += 4; | ||
654 | +#ifdef SWAP_WORDS | ||
655 | + data[0] = bswap32(data[0]); | ||
656 | + data[1] = bswap32(data[1]); | ||
657 | + data[2] = bswap32(data[2]); | ||
658 | +#endif | ||
659 | + b = (data[0] & 0x3f) << 2; | ||
660 | + data[0] >>= 6; | ||
661 | + g = (data[0] & 0x3f) << 2; | ||
662 | + data[0] >>= 6; | ||
663 | + r = (data[0] & 0x3f) << 2; | ||
664 | + data[0] >>= 12; | ||
665 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
666 | + b = (data[0] & 0x3f) << 2; | ||
667 | + data[0] >>= 6; | ||
668 | + g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
669 | + data[1] >>= 4; | ||
670 | + r = (data[1] & 0x3f) << 2; | ||
671 | + data[1] >>= 12; | ||
672 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
673 | + b = (data[1] & 0x3f) << 2; | ||
674 | + data[1] >>= 6; | ||
675 | + g = (data[1] & 0x3f) << 2; | ||
676 | + data[1] >>= 6; | ||
677 | + r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
678 | + data[2] >>= 8; | ||
679 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
680 | + b = (data[2] & 0x3f) << 2; | ||
681 | + data[2] >>= 6; | ||
682 | + g = (data[2] & 0x3f) << 2; | ||
683 | + data[2] >>= 6; | ||
684 | + r = data[2] << 2; | ||
685 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
686 | + width -= 4; | ||
687 | + } | ||
688 | +} | ||
689 | + | ||
690 | +static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src, | ||
691 | + int width, int deststep) | ||
692 | +{ | ||
693 | + uint32_t data; | ||
694 | + unsigned int r, g, b; | ||
695 | + while (width > 0) { | ||
696 | + data = *(uint32_t *) src; | ||
697 | +#ifdef SWAP_WORDS | ||
698 | + data = bswap32(data); | ||
699 | +#endif | ||
700 | + b = (data & 0x3f) << 2; | ||
701 | + data >>= 6; | ||
702 | + g = (data & 0x3f) << 2; | ||
703 | + data >>= 6; | ||
704 | + r = (data & 0x3f) << 2; | ||
705 | + data >>= 6; | ||
706 | + if (data & 1) { | ||
707 | + SKIP_PIXEL(dest); | ||
708 | + } else { | ||
709 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
710 | + } | ||
711 | + width -= 1; | ||
712 | + src += 4; | ||
713 | + } | ||
714 | +} | ||
715 | + | ||
716 | +/* The wicked packed format */ | ||
717 | +static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
718 | + int width, int deststep) | ||
719 | +{ | ||
720 | + uint32_t data[3]; | ||
721 | + unsigned int r, g, b; | ||
722 | + while (width > 0) { | ||
723 | + data[0] = *(uint32_t *) src; | ||
724 | + src += 4; | ||
725 | + data[1] = *(uint32_t *) src; | ||
726 | + src += 4; | ||
727 | + data[2] = *(uint32_t *) src; | ||
728 | + src += 4; | ||
729 | +# ifdef SWAP_WORDS | ||
730 | + data[0] = bswap32(data[0]); | ||
731 | + data[1] = bswap32(data[1]); | ||
732 | + data[2] = bswap32(data[2]); | ||
733 | +# endif | ||
734 | + b = (data[0] & 0x3f) << 2; | ||
735 | + data[0] >>= 6; | ||
736 | + g = (data[0] & 0x3f) << 2; | ||
737 | + data[0] >>= 6; | ||
738 | + r = (data[0] & 0x3f) << 2; | ||
739 | + data[0] >>= 6; | ||
740 | + if (data[0] & 1) { | ||
741 | + SKIP_PIXEL(dest); | ||
742 | + } else { | ||
743 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
744 | + } | ||
745 | + data[0] >>= 6; | ||
746 | + b = (data[0] & 0x3f) << 2; | ||
747 | + data[0] >>= 6; | ||
748 | + g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
749 | + data[1] >>= 4; | ||
750 | + r = (data[1] & 0x3f) << 2; | ||
751 | + data[1] >>= 6; | ||
752 | + if (data[1] & 1) { | ||
753 | + SKIP_PIXEL(dest); | ||
754 | + } else { | ||
755 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
756 | + } | ||
757 | + data[1] >>= 6; | ||
758 | + b = (data[1] & 0x3f) << 2; | ||
759 | + data[1] >>= 6; | ||
760 | + g = (data[1] & 0x3f) << 2; | ||
761 | + data[1] >>= 6; | ||
762 | + r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
763 | + data[2] >>= 2; | ||
764 | + if (data[2] & 1) { | ||
765 | + SKIP_PIXEL(dest); | ||
766 | + } else { | ||
767 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
768 | + } | ||
769 | + data[2] >>= 6; | ||
770 | + b = (data[2] & 0x3f) << 2; | ||
771 | + data[2] >>= 6; | ||
772 | + g = (data[2] & 0x3f) << 2; | ||
773 | + data[2] >>= 6; | ||
774 | + r = data[2] << 2; | ||
775 | + data[2] >>= 6; | ||
776 | + if (data[2] & 1) { | ||
777 | + SKIP_PIXEL(dest); | ||
778 | + } else { | ||
779 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
780 | + } | ||
781 | + width -= 4; | ||
782 | + } | ||
783 | +} | ||
784 | + | ||
785 | +static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src, | ||
786 | + int width, int deststep) | ||
787 | +{ | ||
788 | + uint32_t data; | ||
789 | + unsigned int r, g, b; | ||
790 | + while (width > 0) { | ||
791 | + data = *(uint32_t *) src; | ||
792 | +#ifdef SWAP_WORDS | ||
793 | + data = bswap32(data); | ||
794 | +#endif | ||
795 | + b = data & 0xff; | ||
796 | + data >>= 8; | ||
797 | + g = data & 0xff; | ||
798 | + data >>= 8; | ||
799 | + r = data & 0xff; | ||
800 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
801 | + width -= 1; | ||
802 | + src += 4; | ||
803 | + } | ||
804 | +} | ||
805 | + | ||
806 | +static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
807 | + int width, int deststep) | ||
808 | +{ | ||
809 | + uint32_t data; | ||
810 | + unsigned int r, g, b; | ||
811 | + while (width > 0) { | ||
812 | + data = *(uint32_t *) src; | ||
813 | +#ifdef SWAP_WORDS | ||
814 | + data = bswap32(data); | ||
815 | +#endif | ||
816 | + b = (data & 0x7f) << 1; | ||
817 | + data >>= 7; | ||
818 | + g = data & 0xff; | ||
819 | + data >>= 8; | ||
820 | + r = data & 0xff; | ||
821 | + data >>= 8; | ||
822 | + if (data & 1) { | ||
823 | + SKIP_PIXEL(dest); | ||
824 | + } else { | ||
825 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
826 | + } | ||
827 | + width -= 1; | ||
828 | + src += 4; | ||
829 | + } | ||
830 | +} | ||
831 | + | ||
832 | +static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src, | ||
833 | + int width, int deststep) | ||
834 | +{ | ||
835 | + uint32_t data; | ||
836 | + unsigned int r, g, b; | ||
837 | + while (width > 0) { | ||
838 | + data = *(uint32_t *) src; | ||
839 | +#ifdef SWAP_WORDS | ||
840 | + data = bswap32(data); | ||
841 | +#endif | ||
842 | + b = data & 0xff; | ||
843 | + data >>= 8; | ||
844 | + g = data & 0xff; | ||
845 | + data >>= 8; | ||
846 | + r = data & 0xff; | ||
847 | + data >>= 8; | ||
848 | + if (data & 1) { | ||
849 | + SKIP_PIXEL(dest); | ||
850 | + } else { | ||
851 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
852 | + } | ||
853 | + width -= 1; | ||
854 | + src += 4; | ||
855 | + } | ||
856 | +} | ||
857 | + | ||
858 | +/* Overlay planes disabled, no transparency */ | ||
859 | +static drawfn pxa2xx_draw_fn_32[16] = { | ||
860 | + [0 ... 0xf] = NULL, | ||
861 | + [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
862 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
863 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
864 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16, | ||
865 | + [pxa_lcdc_18bpp] = pxa2xx_draw_line18, | ||
866 | + [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p, | ||
867 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24, | ||
868 | +}; | ||
869 | + | ||
870 | +/* Overlay planes enabled, transparency used */ | ||
871 | +static drawfn pxa2xx_draw_fn_32t[16] = { | ||
872 | + [0 ... 0xf] = NULL, | ||
873 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
874 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
875 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16t, | ||
876 | + [pxa_lcdc_19bpp] = pxa2xx_draw_line19, | ||
877 | + [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p, | ||
878 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24t, | ||
879 | + [pxa_lcdc_25bpp] = pxa2xx_draw_line25, | ||
880 | +}; | ||
881 | + | ||
882 | +#undef COPY_PIXEL | ||
883 | +#undef SKIP_PIXEL | ||
884 | + | ||
885 | +#ifdef SWAP_WORDS | ||
886 | +# undef SWAP_WORDS | ||
887 | +#endif | ||
888 | |||
889 | /* Route internal interrupt lines to the global IC */ | ||
890 | static void pxa2xx_lcdc_int_update(PXA2xxLCDState *s) | ||
891 | -- | ||
892 | 2.20.1 | ||
893 | |||
894 | diff view generated by jsdifflib |