1 | Arm queue; some of the simpler stuff, things other have reviewed (thanks!), etc. | 1 | Some arm patches; my to-review queue is by no means empty, but |
---|---|---|---|
2 | this is a big enough set of patches to be getting on with... | ||
2 | 3 | ||
3 | -- PMM | 4 | -- PMM |
4 | 5 | ||
5 | The following changes since commit 5d2f557b47dfbf8f23277a5bdd8473d4607c681a: | 6 | The following changes since commit cb9c6a8e5ad6a1f0ce164d352e3102df46986e22: |
6 | 7 | ||
7 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200605-pull-request' into staging (2020-06-05 13:53:05 +0100) | 8 | .gitlab-ci.d/windows: Work-around timeout and OpenGL problems of the MSYS2 jobs (2023-01-04 18:58:33 +0000) |
8 | 9 | ||
9 | are available in the Git repository at: | 10 | are available in the Git repository at: |
10 | 11 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200605 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230105 |
12 | 13 | ||
13 | for you to fetch changes up to 2c35a39eda0b16c2ed85c94cec204bf5efb97812: | 14 | for you to fetch changes up to 93c9678de9dc7d2e68f9e8477da072bac30ef132: |
14 | 15 | ||
15 | target/arm: Convert Neon one-register-and-immediate insns to decodetree (2020-06-05 17:23:10 +0100) | 16 | hw/net: Fix read of uninitialized memory in imx_fec. (2023-01-05 15:33:00 +0000) |
16 | 17 | ||
17 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
18 | target-arm queue: | 19 | target-arm queue: |
19 | hw/ssi/imx_spi: Handle tx burst lengths other than 8 correctly | 20 | * Implement AArch32 ARMv8-R support |
20 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 21 | * Add Cortex-R52 CPU |
21 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 22 | * fix handling of HLT semihosting in system mode |
22 | target/arm: Convert crypto insns to gvec | 23 | * hw/timer/ixm_epit: cleanup and fix bug in compare handling |
23 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | 24 | * target/arm: Coding style fixes |
24 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | 25 | * target/arm: Clean up includes |
25 | docs/system: Document Aspeed boards | 26 | * nseries: minor code cleanups |
26 | raspi: Add model of the USB controller | 27 | * target/arm: align exposed ID registers with Linux |
27 | target/arm: Convert 2-reg-and-shift and 1-reg-imm Neon insns to decodetree | 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 | ||
28 | 33 | ||
29 | ---------------------------------------------------------------- | 34 | ---------------------------------------------------------------- |
30 | Cédric Le Goater (1): | 35 | Alex Bennée (1): |
31 | docs/system: Document Aspeed boards | 36 | target/arm: fix handling of HLT semihosting in system mode |
32 | 37 | ||
33 | Eden Mikitas (2): | 38 | Axel Heider (8): |
34 | hw/ssi/imx_spi: changed while statement to prevent underflow | 39 | hw/timer/imx_epit: improve comments |
35 | hw/ssi/imx_spi: Removed unnecessary cast of rx data received from slave | 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 | ||
36 | 47 | ||
37 | Paul Zimmerman (7): | 48 | Claudio Fontana (1): |
38 | raspi: add BCM2835 SOC MPHI emulation | 49 | target/arm: cleanup cpu includes |
39 | dwc-hsotg (dwc2) USB host controller register definitions | ||
40 | dwc-hsotg (dwc2) USB host controller state definitions | ||
41 | dwc-hsotg (dwc2) USB host controller emulation | ||
42 | usb: add short-packet handling to usb-storage driver | ||
43 | wire in the dwc-hsotg (dwc2) USB host controller emulation | ||
44 | raspi2 acceptance test: add test for dwc-hsotg (dwc2) USB host | ||
45 | 50 | ||
46 | Peter Maydell (9): | 51 | Fabiano Rosas (5): |
47 | target/arm: Convert Neon VSHL and VSLI 2-reg-shift insn to decodetree | 52 | target/arm: Fix checkpatch comment style warnings in helper.c |
48 | target/arm: Convert Neon VSHR 2-reg-shift insns to decodetree | 53 | target/arm: Fix checkpatch space errors in helper.c |
49 | target/arm: Convert Neon VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree | 54 | target/arm: Fix checkpatch brace errors in helper.c |
50 | target/arm: Convert VQSHLU, VQSHL 2-reg-shift insns to decodetree | 55 | target/arm: Remove unused includes from m_helper.c |
51 | target/arm: Convert Neon narrowing shifts with op==8 to decodetree | 56 | target/arm: Remove unused includes from helper.c |
52 | target/arm: Convert Neon narrowing shifts with op==9 to decodetree | ||
53 | target/arm: Convert Neon VSHLL, VMOVL to decodetree | ||
54 | target/arm: Convert VCVT fixed-point ops to decodetree | ||
55 | target/arm: Convert Neon one-register-and-immediate insns to decodetree | ||
56 | 57 | ||
57 | Philippe Mathieu-Daudé (3): | 58 | Jean-Christophe Dubois (4): |
58 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 59 | i.MX7D: Connect GPT timers to IRQ |
59 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 60 | i.MX7D: Compute clock frequency for the fixed frequency clocks. |
60 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | 61 | i.MX6UL: Add a specific GPT timer instance for the i.MX6UL |
62 | i.MX7D: Connect IRQs to GPIO devices. | ||
61 | 63 | ||
62 | Richard Henderson (6): | 64 | Peter Maydell (1): |
63 | target/arm: Convert aes and sm4 to gvec helpers | 65 | target/arm:Set lg_page_size to 0 if either S1 or S2 asks for it |
64 | target/arm: Convert rax1 to gvec helpers | ||
65 | target/arm: Convert sha512 and sm3 to gvec helpers | ||
66 | target/arm: Convert sha1 and sha256 to gvec helpers | ||
67 | target/arm: Split helper_crypto_sha1_3reg | ||
68 | target/arm: Split helper_crypto_sm3tt | ||
69 | 66 | ||
70 | Thomas Huth (1): | 67 | Philippe Mathieu-Daudé (5): |
71 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | 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 | ||
72 | 73 | ||
73 | docs/system/arm/aspeed.rst | 85 ++ | 74 | Stephen Longfield (1): |
74 | docs/system/target-arm.rst | 1 + | 75 | hw/net: Fix read of uninitialized memory in imx_fec. |
75 | hw/usb/hcd-dwc2.h | 190 +++++ | ||
76 | include/hw/arm/bcm2835_peripherals.h | 5 +- | ||
77 | include/hw/misc/bcm2835_mphi.h | 44 + | ||
78 | include/hw/usb/dwc2-regs.h | 899 ++++++++++++++++++++ | ||
79 | target/arm/helper.h | 45 +- | ||
80 | target/arm/translate-a64.h | 3 + | ||
81 | target/arm/vec_internal.h | 33 + | ||
82 | target/arm/neon-dp.decode | 214 ++++- | ||
83 | hw/adc/stm32f2xx_adc.c | 4 +- | ||
84 | hw/arm/bcm2835_peripherals.c | 38 +- | ||
85 | hw/arm/pxa2xx.c | 66 +- | ||
86 | hw/input/pxa2xx_keypad.c | 10 +- | ||
87 | hw/misc/bcm2835_mphi.c | 191 +++++ | ||
88 | hw/ssi/imx_spi.c | 4 +- | ||
89 | hw/usb/dev-storage.c | 15 +- | ||
90 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++ | ||
91 | target/arm/crypto_helper.c | 267 ++++-- | ||
92 | target/arm/translate-a64.c | 198 ++--- | ||
93 | target/arm/translate-neon.inc.c | 796 ++++++++++++++---- | ||
94 | target/arm/translate.c | 539 +----------- | ||
95 | target/arm/vec_helper.c | 12 +- | ||
96 | hw/misc/Makefile.objs | 1 + | ||
97 | hw/usb/Kconfig | 5 + | ||
98 | hw/usb/Makefile.objs | 1 + | ||
99 | hw/usb/trace-events | 50 ++ | ||
100 | tests/acceptance/boot_linux_console.py | 35 +- | ||
101 | 28 files changed, 4258 insertions(+), 910 deletions(-) | ||
102 | create mode 100644 docs/system/arm/aspeed.rst | ||
103 | create mode 100644 hw/usb/hcd-dwc2.h | ||
104 | create mode 100644 include/hw/misc/bcm2835_mphi.h | ||
105 | create mode 100644 include/hw/usb/dwc2-regs.h | ||
106 | create mode 100644 target/arm/vec_internal.h | ||
107 | create mode 100644 hw/misc/bcm2835_mphi.c | ||
108 | create mode 100644 hw/usb/hcd-dwc2.c | ||
109 | 76 | ||
77 | Tobias Röhmel (7): | ||
78 | target/arm: Don't add all MIDR aliases for cores that implement PMSA | ||
79 | target/arm: Make RVBAR available for all ARMv8 CPUs | ||
80 | target/arm: Make stage_2_format for cache attributes optional | ||
81 | target/arm: Enable TTBCR_EAE for ARMv8-R AArch32 | ||
82 | target/arm: Add PMSAv8r registers | ||
83 | target/arm: Add PMSAv8r functionality | ||
84 | target/arm: Add ARM Cortex-R52 CPU | ||
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 | Convert the insns in the one-register-and-immediate group to decodetree. | 1 | In get_phys_addr_twostage() we set the lg_page_size of the result to |
---|---|---|---|
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. | ||
2 | 13 | ||
3 | In the new decode, our asimd_imm_const() function returns a 64-bit value | 14 | This has no effect for VMSA because currently the VMSA lookup always |
4 | rather than a 32-bit one, which means we don't need to treat cmode=14 op=1 | 15 | returns results that cover at least TARGET_PAGE_SIZE; however when we |
5 | as a special case in the decoder (it is the only encoding where the two | 16 | add v8R support it will reuse this code path, and for v8R the S1 and |
6 | halves of the 64-bit value are different). | 17 | S2 results can be smaller than TARGET_PAGE_SIZE. |
7 | 18 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200522145520.6778-10-peter.maydell@linaro.org | 21 | Message-id: 20221212142708.610090-1-peter.maydell@linaro.org |
11 | --- | 22 | --- |
12 | target/arm/neon-dp.decode | 22 ++++++ | 23 | target/arm/ptw.c | 16 +++++++++++++--- |
13 | target/arm/translate-neon.inc.c | 118 ++++++++++++++++++++++++++++++++ | 24 | 1 file changed, 13 insertions(+), 3 deletions(-) |
14 | target/arm/translate.c | 101 +-------------------------- | ||
15 | 3 files changed, 142 insertions(+), 99 deletions(-) | ||
16 | 25 | ||
17 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 26 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
18 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/neon-dp.decode | 28 | --- a/target/arm/ptw.c |
20 | +++ b/target/arm/neon-dp.decode | 29 | +++ b/target/arm/ptw.c |
21 | @@ -XXX,XX +XXX,XX @@ VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 30 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
22 | VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 31 | } |
23 | VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 32 | |
24 | VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 33 | /* |
25 | + | 34 | - * Use the maximum of the S1 & S2 page size, so that invalidation |
26 | +###################################################################### | 35 | - * of pages > TARGET_PAGE_SIZE works correctly. |
27 | +# 1-reg-and-modified-immediate grouping: | 36 | + * If either S1 or S2 returned a result smaller than TARGET_PAGE_SIZE, |
28 | +# 1111 001 i 1 D 000 imm:3 Vd:4 cmode:4 0 Q op 1 Vm:4 | 37 | + * this means "don't put this in the TLB"; in this case, return a |
29 | +###################################################################### | 38 | + * result with lg_page_size == 0 to achieve that. Otherwise, |
30 | + | 39 | + * use the maximum of the S1 & S2 page size, so that invalidation |
31 | +&1reg_imm vd q imm cmode op | 40 | + * of pages > TARGET_PAGE_SIZE works correctly. (This works even though |
32 | + | 41 | + * we know the combined result permissions etc only cover the minimum |
33 | +%asimd_imm_value 24:1 16:3 0:4 | 42 | + * of the S1 and S2 page size, because we know that the common TLB code |
34 | + | 43 | + * never actually creates TLB entries bigger than TARGET_PAGE_SIZE, |
35 | +@1reg_imm .... ... . . . ... ... .... .... . q:1 . . .... \ | 44 | + * and passing a larger page size value only affects invalidations.) |
36 | + &1reg_imm imm=%asimd_imm_value vd=%vd_dp | 45 | */ |
37 | + | 46 | - if (result->f.lg_page_size < s1_lgpgsz) { |
38 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMNV, but | 47 | + if (result->f.lg_page_size < TARGET_PAGE_BITS || |
39 | +# not in a way we can conveniently represent in decodetree without | 48 | + s1_lgpgsz < TARGET_PAGE_BITS) { |
40 | +# a lot of repetition: | 49 | + result->f.lg_page_size = 0; |
41 | +# VORR: op=0, (cmode & 1) && cmode < 12 | 50 | + } else if (result->f.lg_page_size < s1_lgpgsz) { |
42 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | 51 | result->f.lg_page_size = s1_lgpgsz; |
43 | +# VMOV: everything else | 52 | } |
44 | +# So we have a single decode line and check the cmode/op in the | 53 | |
45 | +# trans function. | ||
46 | +Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
47 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate-neon.inc.c | ||
50 | +++ b/target/arm/translate-neon.inc.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | ||
52 | DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | ||
53 | DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | ||
54 | DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | ||
55 | + | ||
56 | +static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
57 | +{ | ||
58 | + /* | ||
59 | + * Expand the encoded constant. | ||
60 | + * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
61 | + * We choose to not special-case this and will behave as if a | ||
62 | + * valid constant encoding of 0 had been given. | ||
63 | + * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
64 | + */ | ||
65 | + switch (cmode) { | ||
66 | + case 0: case 1: | ||
67 | + /* no-op */ | ||
68 | + break; | ||
69 | + case 2: case 3: | ||
70 | + imm <<= 8; | ||
71 | + break; | ||
72 | + case 4: case 5: | ||
73 | + imm <<= 16; | ||
74 | + break; | ||
75 | + case 6: case 7: | ||
76 | + imm <<= 24; | ||
77 | + break; | ||
78 | + case 8: case 9: | ||
79 | + imm |= imm << 16; | ||
80 | + break; | ||
81 | + case 10: case 11: | ||
82 | + imm = (imm << 8) | (imm << 24); | ||
83 | + break; | ||
84 | + case 12: | ||
85 | + imm = (imm << 8) | 0xff; | ||
86 | + break; | ||
87 | + case 13: | ||
88 | + imm = (imm << 16) | 0xffff; | ||
89 | + break; | ||
90 | + case 14: | ||
91 | + if (op) { | ||
92 | + /* | ||
93 | + * This is the only case where the top and bottom 32 bits | ||
94 | + * of the encoded constant differ. | ||
95 | + */ | ||
96 | + uint64_t imm64 = 0; | ||
97 | + int n; | ||
98 | + | ||
99 | + for (n = 0; n < 8; n++) { | ||
100 | + if (imm & (1 << n)) { | ||
101 | + imm64 |= (0xffULL << (n * 8)); | ||
102 | + } | ||
103 | + } | ||
104 | + return imm64; | ||
105 | + } | ||
106 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
107 | + break; | ||
108 | + case 15: | ||
109 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
110 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
111 | + break; | ||
112 | + } | ||
113 | + if (op) { | ||
114 | + imm = ~imm; | ||
115 | + } | ||
116 | + return dup_const(MO_32, imm); | ||
117 | +} | ||
118 | + | ||
119 | +static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
120 | + GVecGen2iFn *fn) | ||
121 | +{ | ||
122 | + uint64_t imm; | ||
123 | + int reg_ofs, vec_size; | ||
124 | + | ||
125 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
126 | + return false; | ||
127 | + } | ||
128 | + | ||
129 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
130 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + | ||
134 | + if (a->vd & a->q) { | ||
135 | + return false; | ||
136 | + } | ||
137 | + | ||
138 | + if (!vfp_access_check(s)) { | ||
139 | + return true; | ||
140 | + } | ||
141 | + | ||
142 | + reg_ofs = neon_reg_offset(a->vd, 0); | ||
143 | + vec_size = a->q ? 16 : 8; | ||
144 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
145 | + | ||
146 | + fn(MO_64, reg_ofs, reg_ofs, imm, vec_size, vec_size); | ||
147 | + return true; | ||
148 | +} | ||
149 | + | ||
150 | +static void gen_VMOV_1r(unsigned vece, uint32_t dofs, uint32_t aofs, | ||
151 | + int64_t c, uint32_t oprsz, uint32_t maxsz) | ||
152 | +{ | ||
153 | + tcg_gen_gvec_dup_imm(MO_64, dofs, oprsz, maxsz, c); | ||
154 | +} | ||
155 | + | ||
156 | +static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a) | ||
157 | +{ | ||
158 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ | ||
159 | + GVecGen2iFn *fn; | ||
160 | + | ||
161 | + if ((a->cmode & 1) && a->cmode < 12) { | ||
162 | + /* for op=1, the imm will be inverted, so BIC becomes AND. */ | ||
163 | + fn = a->op ? tcg_gen_gvec_andi : tcg_gen_gvec_ori; | ||
164 | + } else { | ||
165 | + /* There is one unallocated cmode/op combination in this space */ | ||
166 | + if (a->cmode == 15 && a->op == 1) { | ||
167 | + return false; | ||
168 | + } | ||
169 | + fn = gen_VMOV_1r; | ||
170 | + } | ||
171 | + return do_1reg_imm(s, a, fn); | ||
172 | +} | ||
173 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/translate.c | ||
176 | +++ b/target/arm/translate.c | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | /* Three register same length: handled by decodetree */ | ||
179 | return 1; | ||
180 | } else if (insn & (1 << 4)) { | ||
181 | - if ((insn & 0x00380080) != 0) { | ||
182 | - /* Two registers and shift: handled by decodetree */ | ||
183 | - return 1; | ||
184 | - } else { /* (insn & 0x00380080) == 0 */ | ||
185 | - int invert, reg_ofs, vec_size; | ||
186 | - | ||
187 | - if (q && (rd & 1)) { | ||
188 | - return 1; | ||
189 | - } | ||
190 | - | ||
191 | - op = (insn >> 8) & 0xf; | ||
192 | - /* One register and immediate. */ | ||
193 | - imm = (u << 7) | ((insn >> 12) & 0x70) | (insn & 0xf); | ||
194 | - invert = (insn & (1 << 5)) != 0; | ||
195 | - /* Note that op = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
196 | - * We choose to not special-case this and will behave as if a | ||
197 | - * valid constant encoding of 0 had been given. | ||
198 | - */ | ||
199 | - switch (op) { | ||
200 | - case 0: case 1: | ||
201 | - /* no-op */ | ||
202 | - break; | ||
203 | - case 2: case 3: | ||
204 | - imm <<= 8; | ||
205 | - break; | ||
206 | - case 4: case 5: | ||
207 | - imm <<= 16; | ||
208 | - break; | ||
209 | - case 6: case 7: | ||
210 | - imm <<= 24; | ||
211 | - break; | ||
212 | - case 8: case 9: | ||
213 | - imm |= imm << 16; | ||
214 | - break; | ||
215 | - case 10: case 11: | ||
216 | - imm = (imm << 8) | (imm << 24); | ||
217 | - break; | ||
218 | - case 12: | ||
219 | - imm = (imm << 8) | 0xff; | ||
220 | - break; | ||
221 | - case 13: | ||
222 | - imm = (imm << 16) | 0xffff; | ||
223 | - break; | ||
224 | - case 14: | ||
225 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
226 | - if (invert) { | ||
227 | - imm = ~imm; | ||
228 | - } | ||
229 | - break; | ||
230 | - case 15: | ||
231 | - if (invert) { | ||
232 | - return 1; | ||
233 | - } | ||
234 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
235 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
236 | - break; | ||
237 | - } | ||
238 | - if (invert) { | ||
239 | - imm = ~imm; | ||
240 | - } | ||
241 | - | ||
242 | - reg_ofs = neon_reg_offset(rd, 0); | ||
243 | - vec_size = q ? 16 : 8; | ||
244 | - | ||
245 | - if (op & 1 && op < 12) { | ||
246 | - if (invert) { | ||
247 | - /* The immediate value has already been inverted, | ||
248 | - * so BIC becomes AND. | ||
249 | - */ | ||
250 | - tcg_gen_gvec_andi(MO_32, reg_ofs, reg_ofs, imm, | ||
251 | - vec_size, vec_size); | ||
252 | - } else { | ||
253 | - tcg_gen_gvec_ori(MO_32, reg_ofs, reg_ofs, imm, | ||
254 | - vec_size, vec_size); | ||
255 | - } | ||
256 | - } else { | ||
257 | - /* VMOV, VMVN. */ | ||
258 | - if (op == 14 && invert) { | ||
259 | - TCGv_i64 t64 = tcg_temp_new_i64(); | ||
260 | - | ||
261 | - for (pass = 0; pass <= q; ++pass) { | ||
262 | - uint64_t val = 0; | ||
263 | - int n; | ||
264 | - | ||
265 | - for (n = 0; n < 8; n++) { | ||
266 | - if (imm & (1 << (n + pass * 8))) { | ||
267 | - val |= 0xffull << (n * 8); | ||
268 | - } | ||
269 | - } | ||
270 | - tcg_gen_movi_i64(t64, val); | ||
271 | - neon_store_reg64(t64, rd + pass); | ||
272 | - } | ||
273 | - tcg_temp_free_i64(t64); | ||
274 | - } else { | ||
275 | - tcg_gen_gvec_dup_imm(MO_32, reg_ofs, vec_size, | ||
276 | - vec_size, imm); | ||
277 | - } | ||
278 | - } | ||
279 | - } | ||
280 | + /* Two registers and shift or reg and imm: handled by decodetree */ | ||
281 | + return 1; | ||
282 | } else { /* (insn & 0x00800010 == 0x00800000) */ | ||
283 | if (size != 3) { | ||
284 | op = (insn >> 8) & 0xf; | ||
285 | -- | 54 | -- |
286 | 2.20.1 | 55 | 2.25.1 |
287 | |||
288 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Add a check for functional dwc-hsotg (dwc2) USB host emulation to | 3 | Cores with PMSA have the MPUIR register which has the |
4 | the Raspi 2 acceptance test | 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. | ||
5 | 7 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 8 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
7 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20200520235349.21215-8-pauldzim@gmail.com | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20221206102504.165775-2-tobias.roehmel@rwth-aachen.de | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | tests/acceptance/boot_linux_console.py | 9 +++++++-- | 14 | target/arm/helper.c | 13 +++++++++---- |
12 | 1 file changed, 7 insertions(+), 2 deletions(-) | 15 | 1 file changed, 9 insertions(+), 4 deletions(-) |
13 | 16 | ||
14 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 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/tests/acceptance/boot_linux_console.py | 19 | --- a/target/arm/helper.c |
17 | +++ b/tests/acceptance/boot_linux_console.py | 20 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 21 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
19 | 22 | .access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr, | |
20 | self.vm.set_console() | 23 | .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), |
21 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | 24 | .readfn = midr_read }, |
22 | - serial_kernel_cmdline[uart_id]) | 25 | - /* crn = 0 op1 = 0 crm = 0 op2 = 4,7 : AArch32 aliases of MIDR */ |
23 | + serial_kernel_cmdline[uart_id] + | 26 | - { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, |
24 | + ' root=/dev/mmcblk0p2 rootwait ' + | 27 | - .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, |
25 | + 'dwc_otg.fiq_fsm_enable=0') | 28 | - .access = PL1_R, .resetvalue = cpu->midr }, |
26 | self.vm.add_args('-kernel', kernel_path, | 29 | + /* crn = 0 op1 = 0 crm = 0 op2 = 7 : AArch32 aliases of MIDR */ |
27 | '-dtb', dtb_path, | 30 | { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, |
28 | - '-append', kernel_command_line) | 31 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 7, |
29 | + '-append', kernel_command_line, | 32 | .access = PL1_R, .resetvalue = cpu->midr }, |
30 | + '-device', 'usb-kbd') | 33 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
31 | self.vm.launch() | 34 | .accessfn = access_aa64_tid1, |
32 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 35 | .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, |
33 | self.wait_for_console_pattern(console_pattern) | 36 | }; |
34 | + console_pattern = 'Product: QEMU USB Keyboard' | 37 | + ARMCPRegInfo id_v8_midr_alias_cp_reginfo = { |
35 | + self.wait_for_console_pattern(console_pattern) | 38 | + .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, |
36 | 39 | + .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, | |
37 | def test_arm_raspi2_uart0(self): | 40 | + .access = PL1_R, .resetvalue = cpu->midr |
38 | """ | 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) | ||
46 | } | ||
47 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
48 | define_arm_cp_regs(cpu, id_v8_midr_cp_reginfo); | ||
49 | + if (!arm_feature(env, ARM_FEATURE_PMSA)) { | ||
50 | + define_one_arm_cp_reg(cpu, &id_v8_midr_alias_cp_reginfo); | ||
51 | + } | ||
52 | } else { | ||
53 | define_arm_cp_regs(cpu, id_pre_v8_midr_cp_reginfo); | ||
54 | } | ||
39 | -- | 55 | -- |
40 | 2.20.1 | 56 | 2.25.1 |
41 | 57 | ||
42 | 58 | diff view generated by jsdifflib |
1 | Convert the VCVT fixed-point conversion operations in the | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | Neon 2-regs-and-shift group to decodetree. | ||
3 | 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 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200522145520.6778-9-peter.maydell@linaro.org | ||
7 | --- | 12 | --- |
8 | target/arm/neon-dp.decode | 11 +++++ | 13 | target/arm/cpu.c | 6 +++++- |
9 | target/arm/translate-neon.inc.c | 49 +++++++++++++++++++++ | 14 | target/arm/helper.c | 21 ++++++++++++++------- |
10 | target/arm/translate.c | 75 +-------------------------------- | 15 | 2 files changed, 19 insertions(+), 8 deletions(-) |
11 | 3 files changed, 62 insertions(+), 73 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 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/target/arm/neon-dp.decode | 19 | --- a/target/arm/cpu.c |
16 | +++ b/target/arm/neon-dp.decode | 20 | +++ b/target/arm/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 21 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) |
18 | @2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | 22 | env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1, |
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | 23 | CPACR, CP11, 3); |
20 | 24 | #endif | |
21 | +# We use size=0 for fp32 and size=1 for fp16 to match the 3-same encodings. | 25 | + if (arm_feature(env, ARM_FEATURE_V8)) { |
22 | +@2reg_vcvt .... ... . . . 1 ..... .... .... . q:1 . . .... \ | 26 | + env->cp15.rvbar = cpu->rvbar_prop; |
23 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i5 | 27 | + env->regs[15] = cpu->rvbar_prop; |
24 | + | 28 | + } |
25 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 29 | } |
26 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 30 | |
27 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 31 | #if defined(CONFIG_USER_ONLY) |
28 | @@ -XXX,XX +XXX,XX @@ VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | 32 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) |
29 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | 33 | qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_hivecs_property); |
30 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | 34 | } |
31 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | 35 | |
32 | + | 36 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
33 | +# VCVT fixed<->float conversions | 37 | + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { |
34 | +# TODO: FP16 fixed<->float conversions are opc==0b1100 and 0b1101 | 38 | object_property_add_uint64_ptr(obj, "rvbar", |
35 | +VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 39 | &cpu->rvbar_prop, |
36 | +VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 40 | OBJ_PROP_FLAG_READWRITE); |
37 | +VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 41 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
38 | +VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | ||
39 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/translate-neon.inc.c | 43 | --- a/target/arm/helper.c |
42 | +++ b/target/arm/translate-neon.inc.c | 44 | +++ b/target/arm/helper.c |
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | 45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
44 | }; | 46 | if (!arm_feature(env, ARM_FEATURE_EL3) && |
45 | return do_vshll_2sh(s, a, widenfn[a->size], true); | 47 | !arm_feature(env, ARM_FEATURE_EL2)) { |
46 | } | 48 | ARMCPRegInfo rvbar = { |
47 | + | 49 | - .name = "RVBAR_EL1", .state = ARM_CP_STATE_AA64, |
48 | +static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | 50 | + .name = "RVBAR_EL1", .state = ARM_CP_STATE_BOTH, |
49 | + NeonGenTwoSingleOPFn *fn) | 51 | .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1, |
50 | +{ | 52 | .access = PL1_R, |
51 | + /* FP operations in 2-reg-and-shift group */ | 53 | .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
52 | + TCGv_i32 tmp, shiftv; | 54 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
53 | + TCGv_ptr fpstatus; | 55 | } |
54 | + int pass; | 56 | /* RVBAR_EL2 is only implemented if EL2 is the highest EL */ |
55 | + | 57 | if (!arm_feature(env, ARM_FEATURE_EL3)) { |
56 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 58 | - ARMCPRegInfo rvbar = { |
57 | + return false; | 59 | - .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64, |
58 | + } | 60 | - .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1, |
59 | + | 61 | - .access = PL2_R, |
60 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 62 | - .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
61 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 63 | + ARMCPRegInfo rvbar[] = { |
62 | + ((a->vd | a->vm) & 0x10)) { | 64 | + { |
63 | + return false; | 65 | + .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64, |
64 | + } | 66 | + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1, |
65 | + | 67 | + .access = PL2_R, |
66 | + if ((a->vm | a->vd) & a->q) { | 68 | + .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
67 | + return false; | 69 | + }, |
68 | + } | 70 | + { .name = "RVBAR", .type = ARM_CP_ALIAS, |
69 | + | 71 | + .cp = 15, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1, |
70 | + if (!vfp_access_check(s)) { | 72 | + .access = PL2_R, |
71 | + return true; | 73 | + .fieldoffset = offsetof(CPUARMState, cp15.rvbar), |
72 | + } | 74 | + }, |
73 | + | 75 | }; |
74 | + fpstatus = get_fpstatus_ptr(1); | 76 | - define_one_arm_cp_reg(cpu, &rvbar); |
75 | + shiftv = tcg_const_i32(a->shift); | 77 | + define_arm_cp_regs(cpu, rvbar); |
76 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | 78 | } |
77 | + tmp = neon_load_reg(a->vm, pass); | 79 | } |
78 | + fn(tmp, tmp, shiftv, fpstatus); | ||
79 | + neon_store_reg(a->vd, pass, tmp); | ||
80 | + } | ||
81 | + tcg_temp_free_ptr(fpstatus); | ||
82 | + tcg_temp_free_i32(shiftv); | ||
83 | + return true; | ||
84 | +} | ||
85 | + | ||
86 | +#define DO_FP_2SH(INSN, FUNC) \ | ||
87 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
88 | + { \ | ||
89 | + return do_fp_2sh(s, a, FUNC); \ | ||
90 | + } | ||
91 | + | ||
92 | +DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | ||
93 | +DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | ||
94 | +DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | ||
95 | +DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
101 | int q; | ||
102 | int rd, rn, rm, rd_ofs, rn_ofs, rm_ofs; | ||
103 | int size; | ||
104 | - int shift; | ||
105 | int pass; | ||
106 | int u; | ||
107 | int vec_size; | ||
108 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
109 | return 1; | ||
110 | } else if (insn & (1 << 4)) { | ||
111 | if ((insn & 0x00380080) != 0) { | ||
112 | - /* Two registers and shift. */ | ||
113 | - op = (insn >> 8) & 0xf; | ||
114 | - | ||
115 | - switch (op) { | ||
116 | - case 0: /* VSHR */ | ||
117 | - case 1: /* VSRA */ | ||
118 | - case 2: /* VRSHR */ | ||
119 | - case 3: /* VRSRA */ | ||
120 | - case 4: /* VSRI */ | ||
121 | - case 5: /* VSHL, VSLI */ | ||
122 | - case 6: /* VQSHLU */ | ||
123 | - case 7: /* VQSHL */ | ||
124 | - case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
125 | - case 9: /* VQSHRN, VQRSHRN */ | ||
126 | - case 10: /* VSHLL, including VMOVL */ | ||
127 | - return 1; /* handled by decodetree */ | ||
128 | - default: | ||
129 | - break; | ||
130 | - } | ||
131 | - | ||
132 | - if (insn & (1 << 7)) { | ||
133 | - /* 64-bit shift. */ | ||
134 | - if (op > 7) { | ||
135 | - return 1; | ||
136 | - } | ||
137 | - size = 3; | ||
138 | - } else { | ||
139 | - size = 2; | ||
140 | - while ((insn & (1 << (size + 19))) == 0) | ||
141 | - size--; | ||
142 | - } | ||
143 | - shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
144 | - if (op >= 14) { | ||
145 | - /* VCVT fixed-point. */ | ||
146 | - TCGv_ptr fpst; | ||
147 | - TCGv_i32 shiftv; | ||
148 | - VFPGenFixPointFn *fn; | ||
149 | - | ||
150 | - if (!(insn & (1 << 21)) || (q && ((rd | rm) & 1))) { | ||
151 | - return 1; | ||
152 | - } | ||
153 | - | ||
154 | - if (!(op & 1)) { | ||
155 | - if (u) { | ||
156 | - fn = gen_helper_vfp_ultos; | ||
157 | - } else { | ||
158 | - fn = gen_helper_vfp_sltos; | ||
159 | - } | ||
160 | - } else { | ||
161 | - if (u) { | ||
162 | - fn = gen_helper_vfp_touls_round_to_zero; | ||
163 | - } else { | ||
164 | - fn = gen_helper_vfp_tosls_round_to_zero; | ||
165 | - } | ||
166 | - } | ||
167 | - | ||
168 | - /* We have already masked out the must-be-1 top bit of imm6, | ||
169 | - * hence this 32-shift where the ARM ARM has 64-imm6. | ||
170 | - */ | ||
171 | - shift = 32 - shift; | ||
172 | - fpst = get_fpstatus_ptr(1); | ||
173 | - shiftv = tcg_const_i32(shift); | ||
174 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
175 | - TCGv_i32 tmpf = neon_load_reg(rm, pass); | ||
176 | - fn(tmpf, tmpf, shiftv, fpst); | ||
177 | - neon_store_reg(rd, pass, tmpf); | ||
178 | - } | ||
179 | - tcg_temp_free_ptr(fpst); | ||
180 | - tcg_temp_free_i32(shiftv); | ||
181 | - } else { | ||
182 | - return 1; | ||
183 | - } | ||
184 | + /* Two registers and shift: handled by decodetree */ | ||
185 | + return 1; | ||
186 | } else { /* (insn & 0x00380080) == 0 */ | ||
187 | int invert, reg_ofs, vec_size; | ||
188 | 80 | ||
189 | -- | 81 | -- |
190 | 2.20.1 | 82 | 2.25.1 |
191 | 83 | ||
192 | 84 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | The dwc-hsotg (dwc2) USB host depends on a short packet to | 3 | The v8R PMSAv8 has a two-stage MPU translation process, but, unlike |
4 | indicate the end of an IN transfer. The usb-storage driver | 4 | VMSAv8, the stage 2 attributes are in the same format as the stage 1 |
5 | currently doesn't provide this, so fix it. | 5 | attributes (8-bit MAIR format). Rather than converting the MAIR |
6 | format to the format used for VMSA stage 2 (bits [5:2] of a VMSA | ||
7 | stage 2 descriptor) and then converting back to do the attribute | ||
8 | combination, allow combined_attrs_nofwb() to accept s2 attributes | ||
9 | that are already in the MAIR format. | ||
6 | 10 | ||
7 | I have tested this change rather extensively using a PC | 11 | We move the assert() to combined_attrs_fwb(), because that function |
8 | emulation with xhci, ehci, and uhci controllers, and have | 12 | really does require a VMSA stage 2 attribute format. (We will never |
9 | not observed any regressions. | 13 | get there for v8R, because PMSAv8 does not implement FEAT_S2FWB.) |
10 | 14 | ||
11 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 15 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
12 | Message-id: 20200520235349.21215-6-pauldzim@gmail.com | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Message-id: 20221206102504.165775-4-tobias.roehmel@rwth-aachen.de | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 19 | --- |
15 | hw/usb/dev-storage.c | 15 ++++++++++++++- | 20 | target/arm/ptw.c | 10 ++++++++-- |
16 | 1 file changed, 14 insertions(+), 1 deletion(-) | 21 | 1 file changed, 8 insertions(+), 2 deletions(-) |
17 | 22 | ||
18 | diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c | 23 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
19 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/usb/dev-storage.c | 25 | --- a/target/arm/ptw.c |
21 | +++ b/hw/usb/dev-storage.c | 26 | +++ b/target/arm/ptw.c |
22 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_copy_data(MSDState *s, USBPacket *p) | 27 | @@ -XXX,XX +XXX,XX @@ static uint8_t combined_attrs_nofwb(uint64_t hcr, |
23 | usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len); | 28 | { |
24 | s->scsi_len -= len; | 29 | uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs; |
25 | s->scsi_off += len; | 30 | |
26 | + if (len > s->data_len) { | 31 | - s2_mair_attrs = convert_stage2_attrs(hcr, s2.attrs); |
27 | + len = s->data_len; | 32 | + if (s2.is_s2_format) { |
33 | + s2_mair_attrs = convert_stage2_attrs(hcr, s2.attrs); | ||
34 | + } else { | ||
35 | + s2_mair_attrs = s2.attrs; | ||
28 | + } | 36 | + } |
29 | s->data_len -= len; | 37 | |
30 | if (s->scsi_len == 0 || s->data_len == 0) { | 38 | s1lo = extract32(s1.attrs, 0, 4); |
31 | scsi_req_continue(s->req); | 39 | s2lo = extract32(s2_mair_attrs, 0, 4); |
32 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r | 40 | @@ -XXX,XX +XXX,XX @@ static uint8_t force_cacheattr_nibble_wb(uint8_t attr) |
33 | if (s->data_len) { | 41 | */ |
34 | int len = (p->iov.size - p->actual_length); | 42 | static uint8_t combined_attrs_fwb(ARMCacheAttrs s1, ARMCacheAttrs s2) |
35 | usb_packet_skip(p, len); | 43 | { |
36 | + if (len > s->data_len) { | 44 | + assert(s2.is_s2_format && !s1.is_s2_format); |
37 | + len = s->data_len; | 45 | + |
38 | + } | 46 | switch (s2.attrs) { |
39 | s->data_len -= len; | 47 | case 7: |
40 | } | 48 | /* Use stage 1 attributes */ |
41 | if (s->data_len == 0) { | 49 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr, |
42 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | 50 | ARMCacheAttrs ret; |
43 | int len = p->iov.size - p->actual_length; | 51 | bool tagged = false; |
44 | if (len) { | 52 | |
45 | usb_packet_skip(p, len); | 53 | - assert(s2.is_s2_format && !s1.is_s2_format); |
46 | + if (len > s->data_len) { | 54 | + assert(!s1.is_s2_format); |
47 | + len = s->data_len; | 55 | ret.is_s2_format = false; |
48 | + } | 56 | |
49 | s->data_len -= len; | 57 | if (s1.attrs == 0xf0) { |
50 | if (s->data_len == 0) { | ||
51 | s->mode = USB_MSDM_CSW; | ||
52 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | ||
53 | int len = p->iov.size - p->actual_length; | ||
54 | if (len) { | ||
55 | usb_packet_skip(p, len); | ||
56 | + if (len > s->data_len) { | ||
57 | + len = s->data_len; | ||
58 | + } | ||
59 | s->data_len -= len; | ||
60 | if (s->data_len == 0) { | ||
61 | s->mode = USB_MSDM_CSW; | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | - if (p->actual_length < p->iov.size) { | ||
66 | + if (p->actual_length < p->iov.size && (p->short_not_ok || | ||
67 | + s->scsi_len >= p->ep->max_packet_size)) { | ||
68 | DPRINTF("Deferring packet %p [wait data-in]\n", p); | ||
69 | s->packet = p; | ||
70 | p->status = USB_RET_ASYNC; | ||
71 | -- | 58 | -- |
72 | 2.20.1 | 59 | 2.25.1 |
73 | 60 | ||
74 | 61 | diff view generated by jsdifflib |
1 | Convert the Neon narrowing shifts where op==8 to decodetree: | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | * VSHRN | ||
3 | * VRSHRN | ||
4 | * VQSHRUN | ||
5 | * VQRSHRUN | ||
6 | 2 | ||
3 | ARMv8-R AArch32 CPUs behave as if TTBCR.EAE is always 1 even | ||
4 | tough they don't have the TTBCR register. | ||
5 | See ARM Architecture Reference Manual Supplement - ARMv8, for the ARMv8-R | ||
6 | AArch32 architecture profile Version:A.c section C1.2. | ||
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-5-tobias.roehmel@rwth-aachen.de | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200522145520.6778-6-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | target/arm/neon-dp.decode | 27 ++++++ | 13 | target/arm/internals.h | 4 ++++ |
12 | target/arm/translate-neon.inc.c | 167 ++++++++++++++++++++++++++++++++ | 14 | target/arm/debug_helper.c | 3 +++ |
13 | target/arm/translate.c | 1 + | 15 | target/arm/tlb_helper.c | 4 ++++ |
14 | 3 files changed, 195 insertions(+) | 16 | 3 files changed, 11 insertions(+) |
15 | 17 | ||
16 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 18 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/neon-dp.decode | 20 | --- a/target/arm/internals.h |
19 | +++ b/target/arm/neon-dp.decode | 21 | +++ b/target/arm/internals.h |
20 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 22 | @@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu); |
21 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 23 | static inline bool extended_addresses_enabled(CPUARMState *env) |
22 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 24 | { |
23 | 25 | uint64_t tcr = env->cp15.tcr_el[arm_is_secure(env) ? 3 : 1]; | |
24 | +# Narrowing right shifts: here the Q bit is part of the opcode decode | 26 | + if (arm_feature(env, ARM_FEATURE_PMSA) && |
25 | +@2reg_shrn_d .... ... . . . 1 ..... .... .... 0 . . . .... \ | 27 | + arm_feature(env, ARM_FEATURE_V8)) { |
26 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 q=0 \ | ||
27 | + shift=%neon_rshift_i5 | ||
28 | +@2reg_shrn_s .... ... . . . 01 .... .... .... 0 . . . .... \ | ||
29 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 q=0 \ | ||
30 | + shift=%neon_rshift_i4 | ||
31 | +@2reg_shrn_h .... ... . . . 001 ... .... .... 0 . . . .... \ | ||
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 \ | ||
33 | + shift=%neon_rshift_i3 | ||
34 | + | ||
35 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
36 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
37 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
38 | @@ -XXX,XX +XXX,XX @@ VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
39 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
40 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
41 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
42 | + | ||
43 | +VSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | ||
44 | +VSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | ||
45 | +VSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | ||
46 | + | ||
47 | +VRSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | ||
48 | +VRSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
49 | +VRSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
50 | + | ||
51 | +VQSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | ||
52 | +VQSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | ||
53 | +VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | ||
54 | + | ||
55 | +VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | ||
56 | +VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
57 | +VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/translate-neon.inc.c | ||
61 | +++ b/target/arm/translate-neon.inc.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | ||
63 | DO_2SHIFT_ENV(VQSHLU, qshlu_s) | ||
64 | DO_2SHIFT_ENV(VQSHL_U, qshl_u) | ||
65 | DO_2SHIFT_ENV(VQSHL_S, qshl_s) | ||
66 | + | ||
67 | +static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | ||
68 | + NeonGenTwo64OpFn *shiftfn, | ||
69 | + NeonGenNarrowEnvFn *narrowfn) | ||
70 | +{ | ||
71 | + /* 2-reg-and-shift narrowing-shift operations, size == 3 case */ | ||
72 | + TCGv_i64 constimm, rm1, rm2; | ||
73 | + TCGv_i32 rd; | ||
74 | + | ||
75 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
76 | + return false; | ||
77 | + } | ||
78 | + | ||
79 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
80 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
81 | + ((a->vd | a->vm) & 0x10)) { | ||
82 | + return false; | ||
83 | + } | ||
84 | + | ||
85 | + if (a->vm & 1) { | ||
86 | + return false; | ||
87 | + } | ||
88 | + | ||
89 | + if (!vfp_access_check(s)) { | ||
90 | + return true; | 28 | + return true; |
91 | + } | 29 | + } |
92 | + | 30 | return arm_el_is_aa64(env, 1) || |
93 | + /* | 31 | (arm_feature(env, ARM_FEATURE_LPAE) && (tcr & TTBCR_EAE)); |
94 | + * This is always a right shift, and the shiftfn is always a | 32 | } |
95 | + * left-shift helper, which thus needs the negated shift count. | 33 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
96 | + */ | 34 | index XXXXXXX..XXXXXXX 100644 |
97 | + constimm = tcg_const_i64(-a->shift); | 35 | --- a/target/arm/debug_helper.c |
98 | + rm1 = tcg_temp_new_i64(); | 36 | +++ b/target/arm/debug_helper.c |
99 | + rm2 = tcg_temp_new_i64(); | 37 | @@ -XXX,XX +XXX,XX @@ static uint32_t arm_debug_exception_fsr(CPUARMState *env) |
100 | + | 38 | |
101 | + /* Load both inputs first to avoid potential overwrite if rm == rd */ | 39 | if (target_el == 2 || arm_el_is_aa64(env, target_el)) { |
102 | + neon_load_reg64(rm1, a->vm); | 40 | using_lpae = true; |
103 | + neon_load_reg64(rm2, a->vm + 1); | 41 | + } else if (arm_feature(env, ARM_FEATURE_PMSA) && |
104 | + | 42 | + arm_feature(env, ARM_FEATURE_V8)) { |
105 | + shiftfn(rm1, rm1, constimm); | 43 | + using_lpae = true; |
106 | + rd = tcg_temp_new_i32(); | 44 | } else { |
107 | + narrowfn(rd, cpu_env, rm1); | 45 | if (arm_feature(env, ARM_FEATURE_LPAE) && |
108 | + neon_store_reg(a->vd, 0, rd); | 46 | (env->cp15.tcr_el[target_el] & TTBCR_EAE)) { |
109 | + | 47 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c |
110 | + shiftfn(rm2, rm2, constimm); | 48 | index XXXXXXX..XXXXXXX 100644 |
111 | + rd = tcg_temp_new_i32(); | 49 | --- a/target/arm/tlb_helper.c |
112 | + narrowfn(rd, cpu_env, rm2); | 50 | +++ b/target/arm/tlb_helper.c |
113 | + neon_store_reg(a->vd, 1, rd); | 51 | @@ -XXX,XX +XXX,XX @@ bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx) |
114 | + | 52 | if (el == 2 || arm_el_is_aa64(env, el)) { |
115 | + tcg_temp_free_i64(rm1); | 53 | return true; |
116 | + tcg_temp_free_i64(rm2); | 54 | } |
117 | + tcg_temp_free_i64(constimm); | 55 | + if (arm_feature(env, ARM_FEATURE_PMSA) && |
118 | + | 56 | + arm_feature(env, ARM_FEATURE_V8)) { |
119 | + return true; | ||
120 | +} | ||
121 | + | ||
122 | +static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
123 | + NeonGenTwoOpFn *shiftfn, | ||
124 | + NeonGenNarrowEnvFn *narrowfn) | ||
125 | +{ | ||
126 | + /* 2-reg-and-shift narrowing-shift operations, size < 3 case */ | ||
127 | + TCGv_i32 constimm, rm1, rm2, rm3, rm4; | ||
128 | + TCGv_i64 rtmp; | ||
129 | + uint32_t imm; | ||
130 | + | ||
131 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
132 | + return false; | ||
133 | + } | ||
134 | + | ||
135 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
136 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
137 | + ((a->vd | a->vm) & 0x10)) { | ||
138 | + return false; | ||
139 | + } | ||
140 | + | ||
141 | + if (a->vm & 1) { | ||
142 | + return false; | ||
143 | + } | ||
144 | + | ||
145 | + if (!vfp_access_check(s)) { | ||
146 | + return true; | 57 | + return true; |
147 | + } | 58 | + } |
148 | + | 59 | if (arm_feature(env, ARM_FEATURE_LPAE) |
149 | + /* | 60 | && (regime_tcr(env, mmu_idx) & TTBCR_EAE)) { |
150 | + * This is always a right shift, and the shiftfn is always a | 61 | return true; |
151 | + * left-shift helper, which thus needs the negated shift count | ||
152 | + * duplicated into each lane of the immediate value. | ||
153 | + */ | ||
154 | + if (a->size == 1) { | ||
155 | + imm = (uint16_t)(-a->shift); | ||
156 | + imm |= imm << 16; | ||
157 | + } else { | ||
158 | + /* size == 2 */ | ||
159 | + imm = -a->shift; | ||
160 | + } | ||
161 | + constimm = tcg_const_i32(imm); | ||
162 | + | ||
163 | + /* Load all inputs first to avoid potential overwrite */ | ||
164 | + rm1 = neon_load_reg(a->vm, 0); | ||
165 | + rm2 = neon_load_reg(a->vm, 1); | ||
166 | + rm3 = neon_load_reg(a->vm + 1, 0); | ||
167 | + rm4 = neon_load_reg(a->vm + 1, 1); | ||
168 | + rtmp = tcg_temp_new_i64(); | ||
169 | + | ||
170 | + shiftfn(rm1, rm1, constimm); | ||
171 | + shiftfn(rm2, rm2, constimm); | ||
172 | + | ||
173 | + tcg_gen_concat_i32_i64(rtmp, rm1, rm2); | ||
174 | + tcg_temp_free_i32(rm2); | ||
175 | + | ||
176 | + narrowfn(rm1, cpu_env, rtmp); | ||
177 | + neon_store_reg(a->vd, 0, rm1); | ||
178 | + | ||
179 | + shiftfn(rm3, rm3, constimm); | ||
180 | + shiftfn(rm4, rm4, constimm); | ||
181 | + tcg_temp_free_i32(constimm); | ||
182 | + | ||
183 | + tcg_gen_concat_i32_i64(rtmp, rm3, rm4); | ||
184 | + tcg_temp_free_i32(rm4); | ||
185 | + | ||
186 | + narrowfn(rm3, cpu_env, rtmp); | ||
187 | + tcg_temp_free_i64(rtmp); | ||
188 | + neon_store_reg(a->vd, 1, rm3); | ||
189 | + return true; | ||
190 | +} | ||
191 | + | ||
192 | +#define DO_2SN_64(INSN, FUNC, NARROWFUNC) \ | ||
193 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
194 | + { \ | ||
195 | + return do_2shift_narrow_64(s, a, FUNC, NARROWFUNC); \ | ||
196 | + } | ||
197 | +#define DO_2SN_32(INSN, FUNC, NARROWFUNC) \ | ||
198 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
199 | + { \ | ||
200 | + return do_2shift_narrow_32(s, a, FUNC, NARROWFUNC); \ | ||
201 | + } | ||
202 | + | ||
203 | +static void gen_neon_narrow_u32(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
204 | +{ | ||
205 | + tcg_gen_extrl_i64_i32(dest, src); | ||
206 | +} | ||
207 | + | ||
208 | +static void gen_neon_narrow_u16(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
209 | +{ | ||
210 | + gen_helper_neon_narrow_u16(dest, src); | ||
211 | +} | ||
212 | + | ||
213 | +static void gen_neon_narrow_u8(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
214 | +{ | ||
215 | + gen_helper_neon_narrow_u8(dest, src); | ||
216 | +} | ||
217 | + | ||
218 | +DO_2SN_64(VSHRN_64, gen_ushl_i64, gen_neon_narrow_u32) | ||
219 | +DO_2SN_32(VSHRN_32, gen_ushl_i32, gen_neon_narrow_u16) | ||
220 | +DO_2SN_32(VSHRN_16, gen_helper_neon_shl_u16, gen_neon_narrow_u8) | ||
221 | + | ||
222 | +DO_2SN_64(VRSHRN_64, gen_helper_neon_rshl_u64, gen_neon_narrow_u32) | ||
223 | +DO_2SN_32(VRSHRN_32, gen_helper_neon_rshl_u32, gen_neon_narrow_u16) | ||
224 | +DO_2SN_32(VRSHRN_16, gen_helper_neon_rshl_u16, gen_neon_narrow_u8) | ||
225 | + | ||
226 | +DO_2SN_64(VQSHRUN_64, gen_sshl_i64, gen_helper_neon_unarrow_sat32) | ||
227 | +DO_2SN_32(VQSHRUN_32, gen_sshl_i32, gen_helper_neon_unarrow_sat16) | ||
228 | +DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | ||
229 | + | ||
230 | +DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | ||
231 | +DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | ||
232 | +DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | ||
233 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
234 | index XXXXXXX..XXXXXXX 100644 | ||
235 | --- a/target/arm/translate.c | ||
236 | +++ b/target/arm/translate.c | ||
237 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
238 | case 5: /* VSHL, VSLI */ | ||
239 | case 6: /* VQSHLU */ | ||
240 | case 7: /* VQSHL */ | ||
241 | + case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
242 | return 1; /* handled by decodetree */ | ||
243 | default: | ||
244 | break; | ||
245 | -- | 62 | -- |
246 | 2.20.1 | 63 | 2.25.1 |
247 | 64 | ||
248 | 65 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller emulation code. | 3 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
4 | Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c. | 4 | Message-id: 20221206102504.165775-6-tobias.roehmel@rwth-aachen.de |
5 | |||
6 | Note that to use this with the dwc-otg driver in the Raspbian | ||
7 | kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" on | ||
8 | the kernel command line. | ||
9 | |||
10 | Emulation of slave mode and of descriptor-DMA mode has not been | ||
11 | implemented yet. These modes are seldom used. | ||
12 | |||
13 | I have used some on-line sources of information while developing | ||
14 | this emulation, including: | ||
15 | |||
16 | http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf | ||
17 | which has a pretty complete description of the controller starting | ||
18 | on page 370. | ||
19 | |||
20 | https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf | ||
21 | which has a description of the controller registers starting on | ||
22 | page 130. | ||
23 | |||
24 | Thanks to Felippe Mathieu-Daude for providing a cleaner method | ||
25 | of implementing the memory regions for the controller registers. | ||
26 | |||
27 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
28 | Message-id: 20200520235349.21215-5-pauldzim@gmail.com | ||
29 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 6 | --- |
32 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++++++++++++ | 7 | target/arm/cpu.h | 6 + |
33 | hw/usb/Kconfig | 5 + | 8 | target/arm/cpu.c | 28 +++- |
34 | hw/usb/Makefile.objs | 1 + | 9 | target/arm/helper.c | 302 +++++++++++++++++++++++++++++++++++++++++++ |
35 | hw/usb/trace-events | 50 ++ | 10 | target/arm/machine.c | 28 ++++ |
36 | 4 files changed, 1473 insertions(+) | 11 | 4 files changed, 360 insertions(+), 4 deletions(-) |
37 | create mode 100644 hw/usb/hcd-dwc2.c | ||
38 | 12 | ||
39 | diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c | 13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
40 | new file mode 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
41 | index XXXXXXX..XXXXXXX | 15 | --- a/target/arm/cpu.h |
42 | --- /dev/null | 16 | +++ b/target/arm/cpu.h |
43 | +++ b/hw/usb/hcd-dwc2.c | 17 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
44 | @@ -XXX,XX +XXX,XX @@ | 18 | }; |
45 | +/* | 19 | uint64_t sctlr_el[4]; |
46 | + * dwc-hsotg (dwc2) USB host controller emulation | 20 | }; |
47 | + * | 21 | + uint64_t vsctlr; /* Virtualization System control register. */ |
48 | + * Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c | 22 | uint64_t cpacr_el1; /* Architectural feature access control register */ |
49 | + * | 23 | uint64_t cptr_el[4]; /* ARMv8 feature trap registers */ |
50 | + * Note that to use this emulation with the dwc-otg driver in the | 24 | uint32_t c1_xscaleauxcr; /* XScale auxiliary control register. */ |
51 | + * Raspbian kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
52 | + * on the kernel command line. | 26 | */ |
53 | + * | 27 | uint32_t *rbar[M_REG_NUM_BANKS]; |
54 | + * Some useful documentation used to develop this emulation can be | 28 | uint32_t *rlar[M_REG_NUM_BANKS]; |
55 | + * found online (as of April 2020) at: | 29 | + uint32_t *hprbar; |
56 | + * | 30 | + uint32_t *hprlar; |
57 | + * http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf | 31 | uint32_t mair0[M_REG_NUM_BANKS]; |
58 | + * which has a pretty complete description of the controller starting | 32 | uint32_t mair1[M_REG_NUM_BANKS]; |
59 | + * on page 370. | 33 | + uint32_t hprselr; |
60 | + * | 34 | } pmsav8; |
61 | + * https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf | 35 | |
62 | + * which has a description of the controller registers starting on | 36 | /* v8M SAU */ |
63 | + * page 130. | 37 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
64 | + * | 38 | bool has_mpu; |
65 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | 39 | /* PMSAv7 MPU number of supported regions */ |
66 | + * | 40 | uint32_t pmsav7_dregion; |
67 | + * This program is free software; you can redistribute it and/or modify | 41 | + /* PMSAv8 MPU number of supported hyp regions */ |
68 | + * it under the terms of the GNU General Public License as published by | 42 | + uint32_t pmsav8r_hdregion; |
69 | + * the Free Software Foundation; either version 2 of the License, or | 43 | /* v8M SAU number of supported regions */ |
70 | + * (at your option) any later version. | 44 | uint32_t sau_sregion; |
71 | + * | 45 | |
72 | + * This program is distributed in the hope that it will be useful, | 46 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
73 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 47 | index XXXXXXX..XXXXXXX 100644 |
74 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 48 | --- a/target/arm/cpu.c |
75 | + * GNU General Public License for more details. | 49 | +++ b/target/arm/cpu.c |
76 | + */ | 50 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) |
77 | + | 51 | sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion); |
78 | +#include "qemu/osdep.h" | 52 | } |
79 | +#include "qemu/units.h" | 53 | } |
80 | +#include "qapi/error.h" | 54 | + |
81 | +#include "hw/usb/dwc2-regs.h" | 55 | + if (cpu->pmsav8r_hdregion > 0) { |
82 | +#include "hw/usb/hcd-dwc2.h" | 56 | + memset(env->pmsav8.hprbar, 0, |
83 | +#include "migration/vmstate.h" | 57 | + sizeof(*env->pmsav8.hprbar) * cpu->pmsav8r_hdregion); |
84 | +#include "trace.h" | 58 | + memset(env->pmsav8.hprlar, 0, |
85 | +#include "qemu/log.h" | 59 | + sizeof(*env->pmsav8.hprlar) * cpu->pmsav8r_hdregion); |
86 | +#include "qemu/error-report.h" | 60 | + } |
87 | +#include "qemu/main-loop.h" | 61 | + |
88 | +#include "hw/qdev-properties.h" | 62 | env->pmsav7.rnr[M_REG_NS] = 0; |
89 | + | 63 | env->pmsav7.rnr[M_REG_S] = 0; |
90 | +#define USB_HZ_FS 12000000 | 64 | env->pmsav8.mair0[M_REG_NS] = 0; |
91 | +#define USB_HZ_HS 96000000 | 65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
92 | +#define USB_FRMINTVL 12000 | 66 | /* MPU can be configured out of a PMSA CPU either by setting has-mpu |
93 | + | 67 | * to false or by setting pmsav7-dregion to 0. |
94 | +/* nifty macros from Arnon's EHCI version */ | 68 | */ |
95 | +#define get_field(data, field) \ | 69 | - if (!cpu->has_mpu) { |
96 | + (((data) & field##_MASK) >> field##_SHIFT) | 70 | - cpu->pmsav7_dregion = 0; |
97 | + | 71 | - } |
98 | +#define set_field(data, newval, field) do { \ | 72 | - if (cpu->pmsav7_dregion == 0) { |
99 | + uint32_t val = *(data); \ | 73 | + if (!cpu->has_mpu || cpu->pmsav7_dregion == 0) { |
100 | + val &= ~field##_MASK; \ | 74 | cpu->has_mpu = false; |
101 | + val |= ((newval) << field##_SHIFT) & field##_MASK; \ | 75 | + cpu->pmsav7_dregion = 0; |
102 | + *(data) = val; \ | 76 | + cpu->pmsav8r_hdregion = 0; |
103 | +} while (0) | 77 | } |
104 | + | 78 | |
105 | +#define get_bit(data, bitmask) \ | 79 | if (arm_feature(env, ARM_FEATURE_PMSA) && |
106 | + (!!((data) & (bitmask))) | 80 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
107 | + | 81 | env->pmsav7.dracr = g_new0(uint32_t, nr); |
108 | +/* update irq line */ | 82 | } |
109 | +static inline void dwc2_update_irq(DWC2State *s) | 83 | } |
110 | +{ | 84 | + |
111 | + static int oldlevel; | 85 | + if (cpu->pmsav8r_hdregion > 0xff) { |
112 | + int level = 0; | 86 | + error_setg(errp, "PMSAv8 MPU EL2 #regions invalid %" PRIu32, |
113 | + | 87 | + cpu->pmsav8r_hdregion); |
114 | + if ((s->gintsts & s->gintmsk) && (s->gahbcfg & GAHBCFG_GLBL_INTR_EN)) { | 88 | + return; |
115 | + level = 1; | 89 | + } |
116 | + } | 90 | + |
117 | + if (level != oldlevel) { | 91 | + if (cpu->pmsav8r_hdregion) { |
118 | + oldlevel = level; | 92 | + env->pmsav8.hprbar = g_new0(uint32_t, |
119 | + trace_usb_dwc2_update_irq(level); | 93 | + cpu->pmsav8r_hdregion); |
120 | + qemu_set_irq(s->irq, level); | 94 | + env->pmsav8.hprlar = g_new0(uint32_t, |
121 | + } | 95 | + cpu->pmsav8r_hdregion); |
122 | +} | 96 | + } |
123 | + | 97 | } |
124 | +/* flag interrupt condition */ | 98 | |
125 | +static inline void dwc2_raise_global_irq(DWC2State *s, uint32_t intr) | 99 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { |
126 | +{ | 100 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
127 | + if (!(s->gintsts & intr)) { | 101 | index XXXXXXX..XXXXXXX 100644 |
128 | + s->gintsts |= intr; | 102 | --- a/target/arm/helper.c |
129 | + trace_usb_dwc2_raise_global_irq(intr); | 103 | +++ b/target/arm/helper.c |
130 | + dwc2_update_irq(s); | 104 | @@ -XXX,XX +XXX,XX @@ static void pmsav7_rgnr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
131 | + } | 105 | raw_write(env, ri, value); |
132 | +} | 106 | } |
133 | + | 107 | |
134 | +static inline void dwc2_lower_global_irq(DWC2State *s, uint32_t intr) | 108 | +static void prbar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
135 | +{ | 109 | + uint64_t value) |
136 | + if (s->gintsts & intr) { | 110 | +{ |
137 | + s->gintsts &= ~intr; | 111 | + ARMCPU *cpu = env_archcpu(env); |
138 | + trace_usb_dwc2_lower_global_irq(intr); | 112 | + |
139 | + dwc2_update_irq(s); | 113 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
140 | + } | 114 | + env->pmsav8.rbar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]] = value; |
141 | +} | 115 | +} |
142 | + | 116 | + |
143 | +static inline void dwc2_raise_host_irq(DWC2State *s, uint32_t host_intr) | 117 | +static uint64_t prbar_read(CPUARMState *env, const ARMCPRegInfo *ri) |
144 | +{ | 118 | +{ |
145 | + if (!(s->haint & host_intr)) { | 119 | + return env->pmsav8.rbar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]]; |
146 | + s->haint |= host_intr; | 120 | +} |
147 | + s->haint &= 0xffff; | 121 | + |
148 | + trace_usb_dwc2_raise_host_irq(host_intr); | 122 | +static void prlar_write(CPUARMState *env, const ARMCPRegInfo *ri, |
149 | + if (s->haint & s->haintmsk) { | 123 | + uint64_t value) |
150 | + dwc2_raise_global_irq(s, GINTSTS_HCHINT); | 124 | +{ |
151 | + } | 125 | + ARMCPU *cpu = env_archcpu(env); |
152 | + } | 126 | + |
153 | +} | 127 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ |
154 | + | 128 | + env->pmsav8.rlar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]] = value; |
155 | +static inline void dwc2_lower_host_irq(DWC2State *s, uint32_t host_intr) | 129 | +} |
156 | +{ | 130 | + |
157 | + if (s->haint & host_intr) { | 131 | +static uint64_t prlar_read(CPUARMState *env, const ARMCPRegInfo *ri) |
158 | + s->haint &= ~host_intr; | 132 | +{ |
159 | + trace_usb_dwc2_lower_host_irq(host_intr); | 133 | + return env->pmsav8.rlar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]]; |
160 | + if (!(s->haint & s->haintmsk)) { | 134 | +} |
161 | + dwc2_lower_global_irq(s, GINTSTS_HCHINT); | 135 | + |
162 | + } | 136 | +static void prselr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
163 | + } | 137 | + uint64_t value) |
164 | +} | 138 | +{ |
165 | + | 139 | + ARMCPU *cpu = env_archcpu(env); |
166 | +static inline void dwc2_update_hc_irq(DWC2State *s, int index) | 140 | + |
167 | +{ | 141 | + /* |
168 | + uint32_t host_intr = 1 << (index >> 3); | 142 | + * Ignore writes that would select not implemented region. |
169 | + | 143 | + * This is architecturally UNPREDICTABLE. |
170 | + if (s->hreg1[index + 2] & s->hreg1[index + 3]) { | 144 | + */ |
171 | + dwc2_raise_host_irq(s, host_intr); | 145 | + if (value >= cpu->pmsav7_dregion) { |
146 | + return; | ||
147 | + } | ||
148 | + | ||
149 | + env->pmsav7.rnr[M_REG_NS] = value; | ||
150 | +} | ||
151 | + | ||
152 | +static void hprbar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
153 | + uint64_t value) | ||
154 | +{ | ||
155 | + ARMCPU *cpu = env_archcpu(env); | ||
156 | + | ||
157 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ | ||
158 | + env->pmsav8.hprbar[env->pmsav8.hprselr] = value; | ||
159 | +} | ||
160 | + | ||
161 | +static uint64_t hprbar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
162 | +{ | ||
163 | + return env->pmsav8.hprbar[env->pmsav8.hprselr]; | ||
164 | +} | ||
165 | + | ||
166 | +static void hprlar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
167 | + uint64_t value) | ||
168 | +{ | ||
169 | + ARMCPU *cpu = env_archcpu(env); | ||
170 | + | ||
171 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ | ||
172 | + env->pmsav8.hprlar[env->pmsav8.hprselr] = value; | ||
173 | +} | ||
174 | + | ||
175 | +static uint64_t hprlar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
176 | +{ | ||
177 | + return env->pmsav8.hprlar[env->pmsav8.hprselr]; | ||
178 | +} | ||
179 | + | ||
180 | +static void hprenr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
181 | + uint64_t value) | ||
182 | +{ | ||
183 | + uint32_t n; | ||
184 | + uint32_t bit; | ||
185 | + ARMCPU *cpu = env_archcpu(env); | ||
186 | + | ||
187 | + /* Ignore writes to unimplemented regions */ | ||
188 | + int rmax = MIN(cpu->pmsav8r_hdregion, 32); | ||
189 | + value &= MAKE_64BIT_MASK(0, rmax); | ||
190 | + | ||
191 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ | ||
192 | + | ||
193 | + /* Register alias is only valid for first 32 indexes */ | ||
194 | + for (n = 0; n < rmax; ++n) { | ||
195 | + bit = extract32(value, n, 1); | ||
196 | + env->pmsav8.hprlar[n] = deposit32( | ||
197 | + env->pmsav8.hprlar[n], 0, 1, bit); | ||
198 | + } | ||
199 | +} | ||
200 | + | ||
201 | +static uint64_t hprenr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
202 | +{ | ||
203 | + uint32_t n; | ||
204 | + uint32_t result = 0x0; | ||
205 | + ARMCPU *cpu = env_archcpu(env); | ||
206 | + | ||
207 | + /* Register alias is only valid for first 32 indexes */ | ||
208 | + for (n = 0; n < MIN(cpu->pmsav8r_hdregion, 32); ++n) { | ||
209 | + if (env->pmsav8.hprlar[n] & 0x1) { | ||
210 | + result |= (0x1 << n); | ||
211 | + } | ||
212 | + } | ||
213 | + return result; | ||
214 | +} | ||
215 | + | ||
216 | +static void hprselr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
217 | + uint64_t value) | ||
218 | +{ | ||
219 | + ARMCPU *cpu = env_archcpu(env); | ||
220 | + | ||
221 | + /* | ||
222 | + * Ignore writes that would select not implemented region. | ||
223 | + * This is architecturally UNPREDICTABLE. | ||
224 | + */ | ||
225 | + if (value >= cpu->pmsav8r_hdregion) { | ||
226 | + return; | ||
227 | + } | ||
228 | + | ||
229 | + env->pmsav8.hprselr = value; | ||
230 | +} | ||
231 | + | ||
232 | +static void pmsav8r_regn_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
233 | + uint64_t value) | ||
234 | +{ | ||
235 | + ARMCPU *cpu = env_archcpu(env); | ||
236 | + uint8_t index = (extract32(ri->opc0, 0, 1) << 4) | | ||
237 | + (extract32(ri->crm, 0, 3) << 1) | extract32(ri->opc2, 2, 1); | ||
238 | + | ||
239 | + tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ | ||
240 | + | ||
241 | + if (ri->opc1 & 4) { | ||
242 | + if (index >= cpu->pmsav8r_hdregion) { | ||
243 | + return; | ||
244 | + } | ||
245 | + if (ri->opc2 & 0x1) { | ||
246 | + env->pmsav8.hprlar[index] = value; | ||
247 | + } else { | ||
248 | + env->pmsav8.hprbar[index] = value; | ||
249 | + } | ||
172 | + } else { | 250 | + } else { |
173 | + dwc2_lower_host_irq(s, host_intr); | 251 | + if (index >= cpu->pmsav7_dregion) { |
174 | + } | 252 | + return; |
175 | +} | 253 | + } |
176 | + | 254 | + if (ri->opc2 & 0x1) { |
177 | +/* set a timer for EOF */ | 255 | + env->pmsav8.rlar[M_REG_NS][index] = value; |
178 | +static void dwc2_eof_timer(DWC2State *s) | 256 | + } else { |
179 | +{ | 257 | + env->pmsav8.rbar[M_REG_NS][index] = value; |
180 | + timer_mod(s->eof_timer, s->sof_time + s->usb_frame_time); | 258 | + } |
181 | +} | 259 | + } |
182 | + | 260 | +} |
183 | +/* Set a timer for EOF and generate SOF event */ | 261 | + |
184 | +static void dwc2_sof(DWC2State *s) | 262 | +static uint64_t pmsav8r_regn_read(CPUARMState *env, const ARMCPRegInfo *ri) |
185 | +{ | 263 | +{ |
186 | + s->sof_time += s->usb_frame_time; | 264 | + ARMCPU *cpu = env_archcpu(env); |
187 | + trace_usb_dwc2_sof(s->sof_time); | 265 | + uint8_t index = (extract32(ri->opc0, 0, 1) << 4) | |
188 | + dwc2_eof_timer(s); | 266 | + (extract32(ri->crm, 0, 3) << 1) | extract32(ri->opc2, 2, 1); |
189 | + dwc2_raise_global_irq(s, GINTSTS_SOF); | 267 | + |
190 | +} | 268 | + if (ri->opc1 & 4) { |
191 | + | 269 | + if (index >= cpu->pmsav8r_hdregion) { |
192 | +/* Do frame processing on frame boundary */ | 270 | + return 0x0; |
193 | +static void dwc2_frame_boundary(void *opaque) | 271 | + } |
194 | +{ | 272 | + if (ri->opc2 & 0x1) { |
195 | + DWC2State *s = opaque; | 273 | + return env->pmsav8.hprlar[index]; |
196 | + int64_t now; | 274 | + } else { |
197 | + uint16_t frcnt; | 275 | + return env->pmsav8.hprbar[index]; |
198 | + | 276 | + } |
199 | + now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
200 | + | ||
201 | + /* Frame boundary, so do EOF stuff here */ | ||
202 | + | ||
203 | + /* Increment frame number */ | ||
204 | + frcnt = (uint16_t)((now - s->sof_time) / s->fi); | ||
205 | + s->frame_number = (s->frame_number + frcnt) & 0xffff; | ||
206 | + s->hfnum = s->frame_number & HFNUM_MAX_FRNUM; | ||
207 | + | ||
208 | + /* Do SOF stuff here */ | ||
209 | + dwc2_sof(s); | ||
210 | +} | ||
211 | + | ||
212 | +/* Start sending SOF tokens on the USB bus */ | ||
213 | +static void dwc2_bus_start(DWC2State *s) | ||
214 | +{ | ||
215 | + trace_usb_dwc2_bus_start(); | ||
216 | + s->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
217 | + dwc2_eof_timer(s); | ||
218 | +} | ||
219 | + | ||
220 | +/* Stop sending SOF tokens on the USB bus */ | ||
221 | +static void dwc2_bus_stop(DWC2State *s) | ||
222 | +{ | ||
223 | + trace_usb_dwc2_bus_stop(); | ||
224 | + timer_del(s->eof_timer); | ||
225 | +} | ||
226 | + | ||
227 | +static USBDevice *dwc2_find_device(DWC2State *s, uint8_t addr) | ||
228 | +{ | ||
229 | + USBDevice *dev; | ||
230 | + | ||
231 | + trace_usb_dwc2_find_device(addr); | ||
232 | + | ||
233 | + if (!(s->hprt0 & HPRT0_ENA)) { | ||
234 | + trace_usb_dwc2_port_disabled(0); | ||
235 | + } else { | 277 | + } else { |
236 | + dev = usb_find_device(&s->uport, addr); | 278 | + if (index >= cpu->pmsav7_dregion) { |
237 | + if (dev != NULL) { | 279 | + return 0x0; |
238 | + trace_usb_dwc2_device_found(0); | 280 | + } |
239 | + return dev; | 281 | + if (ri->opc2 & 0x1) { |
240 | + } | 282 | + return env->pmsav8.rlar[M_REG_NS][index]; |
241 | + } | 283 | + } else { |
242 | + | 284 | + return env->pmsav8.rbar[M_REG_NS][index]; |
243 | + trace_usb_dwc2_device_not_found(); | 285 | + } |
244 | + return NULL; | 286 | + } |
245 | +} | 287 | +} |
246 | + | 288 | + |
247 | +static const char *pstatus[] = { | 289 | +static const ARMCPRegInfo pmsav8r_cp_reginfo[] = { |
248 | + "USB_RET_SUCCESS", "USB_RET_NODEV", "USB_RET_NAK", "USB_RET_STALL", | 290 | + { .name = "PRBAR", |
249 | + "USB_RET_BABBLE", "USB_RET_IOERROR", "USB_RET_ASYNC", | 291 | + .cp = 15, .opc1 = 0, .crn = 6, .crm = 3, .opc2 = 0, |
250 | + "USB_RET_ADD_TO_QUEUE", "USB_RET_REMOVE_FROM_QUEUE" | 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 }, | ||
251 | +}; | 322 | +}; |
252 | + | 323 | + |
253 | +static uint32_t pintr[] = { | 324 | static const ARMCPRegInfo pmsav7_cp_reginfo[] = { |
254 | + HCINTMSK_XFERCOMPL, HCINTMSK_XACTERR, HCINTMSK_NAK, HCINTMSK_STALL, | 325 | /* Reset for all these registers is handled in arm_cpu_reset(), |
255 | + HCINTMSK_BBLERR, HCINTMSK_XACTERR, HCINTMSK_XACTERR, HCINTMSK_XACTERR, | 326 | * because the PMSAv7 is also used by M-profile CPUs, which do |
256 | + HCINTMSK_XACTERR | 327 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
257 | +}; | 328 | .access = PL1_R, .type = ARM_CP_CONST, |
258 | + | 329 | .resetvalue = cpu->pmsav7_dregion << 8 |
259 | +static const char *types[] = { | 330 | }; |
260 | + "Ctrl", "Isoc", "Bulk", "Intr" | 331 | + /* HMPUIR is specific to PMSA V8 */ |
261 | +}; | 332 | + ARMCPRegInfo id_hmpuir_reginfo = { |
262 | + | 333 | + .name = "HMPUIR", |
263 | +static const char *dirs[] = { | 334 | + .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 4, |
264 | + "Out", "In" | 335 | + .access = PL2_R, .type = ARM_CP_CONST, |
265 | +}; | 336 | + .resetvalue = cpu->pmsav8r_hdregion |
266 | + | 337 | + }; |
267 | +static void dwc2_handle_packet(DWC2State *s, uint32_t devadr, USBDevice *dev, | 338 | static const ARMCPRegInfo crn0_wi_reginfo = { |
268 | + USBEndpoint *ep, uint32_t index, bool send) | 339 | .name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY, |
269 | +{ | 340 | .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W, |
270 | + DWC2Packet *p; | 341 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
271 | + uint32_t hcchar = s->hreg1[index]; | 342 | define_arm_cp_regs(cpu, id_cp_reginfo); |
272 | + uint32_t hctsiz = s->hreg1[index + 4]; | 343 | if (!arm_feature(env, ARM_FEATURE_PMSA)) { |
273 | + uint32_t hcdma = s->hreg1[index + 5]; | 344 | define_one_arm_cp_reg(cpu, &id_tlbtr_reginfo); |
274 | + uint32_t chan, epnum, epdir, eptype, mps, pid, pcnt, len, tlen, intr = 0; | 345 | + } else if (arm_feature(env, ARM_FEATURE_PMSA) && |
275 | + uint32_t tpcnt, stsidx, actual = 0; | 346 | + arm_feature(env, ARM_FEATURE_V8)) { |
276 | + bool do_intr = false, done = false; | 347 | + uint32_t i = 0; |
277 | + | 348 | + char *tmp_string; |
278 | + epnum = get_field(hcchar, HCCHAR_EPNUM); | 349 | + |
279 | + epdir = get_bit(hcchar, HCCHAR_EPDIR); | 350 | + define_one_arm_cp_reg(cpu, &id_mpuir_reginfo); |
280 | + eptype = get_field(hcchar, HCCHAR_EPTYPE); | 351 | + define_one_arm_cp_reg(cpu, &id_hmpuir_reginfo); |
281 | + mps = get_field(hcchar, HCCHAR_MPS); | 352 | + define_arm_cp_regs(cpu, pmsav8r_cp_reginfo); |
282 | + pid = get_field(hctsiz, TSIZ_SC_MC_PID); | 353 | + |
283 | + pcnt = get_field(hctsiz, TSIZ_PKTCNT); | 354 | + /* Register alias is only valid for first 32 indexes */ |
284 | + len = get_field(hctsiz, TSIZ_XFERSIZE); | 355 | + for (i = 0; i < MIN(cpu->pmsav7_dregion, 32); ++i) { |
285 | + assert(len <= DWC2_MAX_XFER_SIZE); | 356 | + uint8_t crm = 0b1000 | extract32(i, 1, 3); |
286 | + chan = index >> 3; | 357 | + uint8_t opc1 = extract32(i, 4, 1); |
287 | + p = &s->packet[chan]; | 358 | + uint8_t opc2 = extract32(i, 0, 1) << 2; |
288 | + | 359 | + |
289 | + trace_usb_dwc2_handle_packet(chan, dev, &p->packet, epnum, types[eptype], | 360 | + tmp_string = g_strdup_printf("PRBAR%u", i); |
290 | + dirs[epdir], mps, len, pcnt); | 361 | + ARMCPRegInfo tmp_prbarn_reginfo = { |
291 | + | 362 | + .name = tmp_string, .type = ARM_CP_ALIAS | ARM_CP_NO_RAW, |
292 | + if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) { | 363 | + .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2, |
293 | + pid = USB_TOKEN_SETUP; | 364 | + .access = PL1_RW, .resetvalue = 0, |
294 | + } else { | 365 | + .accessfn = access_tvm_trvm, |
295 | + pid = epdir ? USB_TOKEN_IN : USB_TOKEN_OUT; | 366 | + .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read |
296 | + } | 367 | + }; |
297 | + | 368 | + define_one_arm_cp_reg(cpu, &tmp_prbarn_reginfo); |
298 | + if (send) { | 369 | + g_free(tmp_string); |
299 | + tlen = len; | 370 | + |
300 | + if (p->small) { | 371 | + opc2 = extract32(i, 0, 1) << 2 | 0x1; |
301 | + if (tlen > mps) { | 372 | + tmp_string = g_strdup_printf("PRLAR%u", i); |
302 | + tlen = mps; | 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); | ||
303 | + } | 382 | + } |
304 | + } | 383 | + |
305 | + | 384 | + /* Register alias is only valid for first 32 indexes */ |
306 | + if (pid != USB_TOKEN_IN) { | 385 | + for (i = 0; i < MIN(cpu->pmsav8r_hdregion, 32); ++i) { |
307 | + trace_usb_dwc2_memory_read(hcdma, tlen); | 386 | + uint8_t crm = 0b1000 | extract32(i, 1, 3); |
308 | + if (dma_memory_read(&s->dma_as, hcdma, | 387 | + uint8_t opc1 = 0b100 | extract32(i, 4, 1); |
309 | + s->usb_buf[chan], tlen) != MEMTX_OK) { | 388 | + uint8_t opc2 = extract32(i, 0, 1) << 2; |
310 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_read failed\n", | 389 | + |
311 | + __func__); | 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); | ||
312 | + } | 412 | + } |
313 | + } | 413 | } else if (arm_feature(env, ARM_FEATURE_V7)) { |
314 | + | 414 | define_one_arm_cp_reg(cpu, &id_mpuir_reginfo); |
315 | + usb_packet_init(&p->packet); | 415 | } |
316 | + usb_packet_setup(&p->packet, pid, ep, 0, hcdma, | 416 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
317 | + pid != USB_TOKEN_IN, true); | 417 | sctlr.type |= ARM_CP_SUPPRESS_TB_END; |
318 | + usb_packet_addbuf(&p->packet, s->usb_buf[chan], tlen); | 418 | } |
319 | + p->async = DWC2_ASYNC_NONE; | 419 | define_one_arm_cp_reg(cpu, &sctlr); |
320 | + usb_handle_packet(dev, &p->packet); | 420 | + |
321 | + } else { | 421 | + if (arm_feature(env, ARM_FEATURE_PMSA) && |
322 | + tlen = p->len; | 422 | + arm_feature(env, ARM_FEATURE_V8)) { |
323 | + } | 423 | + ARMCPRegInfo vsctlr = { |
324 | + | 424 | + .name = "VSCTLR", .state = ARM_CP_STATE_AA32, |
325 | + stsidx = -p->packet.status; | 425 | + .cp = 15, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, |
326 | + assert(stsidx < sizeof(pstatus) / sizeof(*pstatus)); | 426 | + .access = PL2_RW, .resetvalue = 0x0, |
327 | + actual = p->packet.actual_length; | 427 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.vsctlr), |
328 | + trace_usb_dwc2_packet_status(pstatus[stsidx], actual); | 428 | + }; |
329 | + | 429 | + define_one_arm_cp_reg(cpu, &vsctlr); |
330 | +babble: | 430 | + } |
331 | + if (p->packet.status != USB_RET_SUCCESS && | 431 | } |
332 | + p->packet.status != USB_RET_NAK && | 432 | |
333 | + p->packet.status != USB_RET_STALL && | 433 | if (cpu_isar_feature(aa64_lor, cpu)) { |
334 | + p->packet.status != USB_RET_ASYNC) { | 434 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
335 | + trace_usb_dwc2_packet_error(pstatus[stsidx]); | 435 | index XXXXXXX..XXXXXXX 100644 |
336 | + } | 436 | --- a/target/arm/machine.c |
337 | + | 437 | +++ b/target/arm/machine.c |
338 | + if (p->packet.status == USB_RET_ASYNC) { | 438 | @@ -XXX,XX +XXX,XX @@ static bool pmsav8_needed(void *opaque) |
339 | + trace_usb_dwc2_async_packet(&p->packet, chan, dev, epnum, | 439 | arm_feature(env, ARM_FEATURE_V8); |
340 | + dirs[epdir], tlen); | 440 | } |
341 | + usb_device_flush_ep_queue(dev, ep); | 441 | |
342 | + assert(p->async != DWC2_ASYNC_INFLIGHT); | 442 | +static bool pmsav8r_needed(void *opaque) |
343 | + p->devadr = devadr; | 443 | +{ |
344 | + p->epnum = epnum; | 444 | + ARMCPU *cpu = opaque; |
345 | + p->epdir = epdir; | 445 | + CPUARMState *env = &cpu->env; |
346 | + p->mps = mps; | 446 | + |
347 | + p->pid = pid; | 447 | + return arm_feature(env, ARM_FEATURE_PMSA) && |
348 | + p->index = index; | 448 | + arm_feature(env, ARM_FEATURE_V8) && |
349 | + p->pcnt = pcnt; | 449 | + !arm_feature(env, ARM_FEATURE_M); |
350 | + p->len = tlen; | 450 | +} |
351 | + p->async = DWC2_ASYNC_INFLIGHT; | 451 | + |
352 | + p->needs_service = false; | 452 | +static const VMStateDescription vmstate_pmsav8r = { |
353 | + return; | 453 | + .name = "cpu/pmsav8/pmsav8r", |
354 | + } | ||
355 | + | ||
356 | + if (p->packet.status == USB_RET_SUCCESS) { | ||
357 | + if (actual > tlen) { | ||
358 | + p->packet.status = USB_RET_BABBLE; | ||
359 | + goto babble; | ||
360 | + } | ||
361 | + | ||
362 | + if (pid == USB_TOKEN_IN) { | ||
363 | + trace_usb_dwc2_memory_write(hcdma, actual); | ||
364 | + if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], | ||
365 | + actual) != MEMTX_OK) { | ||
366 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_write failed\n", | ||
367 | + __func__); | ||
368 | + } | ||
369 | + } | ||
370 | + | ||
371 | + tpcnt = actual / mps; | ||
372 | + if (actual % mps) { | ||
373 | + tpcnt++; | ||
374 | + if (pid == USB_TOKEN_IN) { | ||
375 | + done = true; | ||
376 | + } | ||
377 | + } | ||
378 | + | ||
379 | + pcnt -= tpcnt < pcnt ? tpcnt : pcnt; | ||
380 | + set_field(&hctsiz, pcnt, TSIZ_PKTCNT); | ||
381 | + len -= actual < len ? actual : len; | ||
382 | + set_field(&hctsiz, len, TSIZ_XFERSIZE); | ||
383 | + s->hreg1[index + 4] = hctsiz; | ||
384 | + hcdma += actual; | ||
385 | + s->hreg1[index + 5] = hcdma; | ||
386 | + | ||
387 | + if (!pcnt || len == 0 || actual == 0) { | ||
388 | + done = true; | ||
389 | + } | ||
390 | + } else { | ||
391 | + intr |= pintr[stsidx]; | ||
392 | + if (p->packet.status == USB_RET_NAK && | ||
393 | + (eptype == USB_ENDPOINT_XFER_CONTROL || | ||
394 | + eptype == USB_ENDPOINT_XFER_BULK)) { | ||
395 | + /* | ||
396 | + * for ctrl/bulk, automatically retry on NAK, | ||
397 | + * but send the interrupt anyway | ||
398 | + */ | ||
399 | + intr &= ~HCINTMSK_RESERVED14_31; | ||
400 | + s->hreg1[index + 2] |= intr; | ||
401 | + do_intr = true; | ||
402 | + } else { | ||
403 | + intr |= HCINTMSK_CHHLTD; | ||
404 | + done = true; | ||
405 | + } | ||
406 | + } | ||
407 | + | ||
408 | + usb_packet_cleanup(&p->packet); | ||
409 | + | ||
410 | + if (done) { | ||
411 | + hcchar &= ~HCCHAR_CHENA; | ||
412 | + s->hreg1[index] = hcchar; | ||
413 | + if (!(intr & HCINTMSK_CHHLTD)) { | ||
414 | + intr |= HCINTMSK_CHHLTD | HCINTMSK_XFERCOMPL; | ||
415 | + } | ||
416 | + intr &= ~HCINTMSK_RESERVED14_31; | ||
417 | + s->hreg1[index + 2] |= intr; | ||
418 | + p->needs_service = false; | ||
419 | + trace_usb_dwc2_packet_done(pstatus[stsidx], actual, len, pcnt); | ||
420 | + dwc2_update_hc_irq(s, index); | ||
421 | + return; | ||
422 | + } | ||
423 | + | ||
424 | + p->devadr = devadr; | ||
425 | + p->epnum = epnum; | ||
426 | + p->epdir = epdir; | ||
427 | + p->mps = mps; | ||
428 | + p->pid = pid; | ||
429 | + p->index = index; | ||
430 | + p->pcnt = pcnt; | ||
431 | + p->len = len; | ||
432 | + p->needs_service = true; | ||
433 | + trace_usb_dwc2_packet_next(pstatus[stsidx], len, pcnt); | ||
434 | + if (do_intr) { | ||
435 | + dwc2_update_hc_irq(s, index); | ||
436 | + } | ||
437 | +} | ||
438 | + | ||
439 | +/* Attach or detach a device on root hub */ | ||
440 | + | ||
441 | +static const char *speeds[] = { | ||
442 | + "low", "full", "high" | ||
443 | +}; | ||
444 | + | ||
445 | +static void dwc2_attach(USBPort *port) | ||
446 | +{ | ||
447 | + DWC2State *s = port->opaque; | ||
448 | + int hispd = 0; | ||
449 | + | ||
450 | + trace_usb_dwc2_attach(port); | ||
451 | + assert(port->index == 0); | ||
452 | + | ||
453 | + if (!port->dev || !port->dev->attached) { | ||
454 | + return; | ||
455 | + } | ||
456 | + | ||
457 | + assert(port->dev->speed <= USB_SPEED_HIGH); | ||
458 | + trace_usb_dwc2_attach_speed(speeds[port->dev->speed]); | ||
459 | + s->hprt0 &= ~HPRT0_SPD_MASK; | ||
460 | + | ||
461 | + switch (port->dev->speed) { | ||
462 | + case USB_SPEED_LOW: | ||
463 | + s->hprt0 |= HPRT0_SPD_LOW_SPEED << HPRT0_SPD_SHIFT; | ||
464 | + break; | ||
465 | + case USB_SPEED_FULL: | ||
466 | + s->hprt0 |= HPRT0_SPD_FULL_SPEED << HPRT0_SPD_SHIFT; | ||
467 | + break; | ||
468 | + case USB_SPEED_HIGH: | ||
469 | + s->hprt0 |= HPRT0_SPD_HIGH_SPEED << HPRT0_SPD_SHIFT; | ||
470 | + hispd = 1; | ||
471 | + break; | ||
472 | + } | ||
473 | + | ||
474 | + if (hispd) { | ||
475 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 8000; /* 125000 */ | ||
476 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_HS) { | ||
477 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_HS; /* 10.4 */ | ||
478 | + } else { | ||
479 | + s->usb_bit_time = 1; | ||
480 | + } | ||
481 | + } else { | ||
482 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 1000; /* 1000000 */ | ||
483 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_FS) { | ||
484 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_FS; /* 83.3 */ | ||
485 | + } else { | ||
486 | + s->usb_bit_time = 1; | ||
487 | + } | ||
488 | + } | ||
489 | + | ||
490 | + s->fi = USB_FRMINTVL - 1; | ||
491 | + s->hprt0 |= HPRT0_CONNDET | HPRT0_CONNSTS; | ||
492 | + | ||
493 | + dwc2_bus_start(s); | ||
494 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
495 | +} | ||
496 | + | ||
497 | +static void dwc2_detach(USBPort *port) | ||
498 | +{ | ||
499 | + DWC2State *s = port->opaque; | ||
500 | + | ||
501 | + trace_usb_dwc2_detach(port); | ||
502 | + assert(port->index == 0); | ||
503 | + | ||
504 | + dwc2_bus_stop(s); | ||
505 | + | ||
506 | + s->hprt0 &= ~(HPRT0_SPD_MASK | HPRT0_SUSP | HPRT0_ENA | HPRT0_CONNSTS); | ||
507 | + s->hprt0 |= HPRT0_CONNDET | HPRT0_ENACHG; | ||
508 | + | ||
509 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
510 | +} | ||
511 | + | ||
512 | +static void dwc2_child_detach(USBPort *port, USBDevice *child) | ||
513 | +{ | ||
514 | + trace_usb_dwc2_child_detach(port, child); | ||
515 | + assert(port->index == 0); | ||
516 | +} | ||
517 | + | ||
518 | +static void dwc2_wakeup(USBPort *port) | ||
519 | +{ | ||
520 | + DWC2State *s = port->opaque; | ||
521 | + | ||
522 | + trace_usb_dwc2_wakeup(port); | ||
523 | + assert(port->index == 0); | ||
524 | + | ||
525 | + if (s->hprt0 & HPRT0_SUSP) { | ||
526 | + s->hprt0 |= HPRT0_RES; | ||
527 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
528 | + } | ||
529 | + | ||
530 | + qemu_bh_schedule(s->async_bh); | ||
531 | +} | ||
532 | + | ||
533 | +static void dwc2_async_packet_complete(USBPort *port, USBPacket *packet) | ||
534 | +{ | ||
535 | + DWC2State *s = port->opaque; | ||
536 | + DWC2Packet *p; | ||
537 | + USBDevice *dev; | ||
538 | + USBEndpoint *ep; | ||
539 | + | ||
540 | + assert(port->index == 0); | ||
541 | + p = container_of(packet, DWC2Packet, packet); | ||
542 | + dev = dwc2_find_device(s, p->devadr); | ||
543 | + ep = usb_ep_get(dev, p->pid, p->epnum); | ||
544 | + trace_usb_dwc2_async_packet_complete(port, packet, p->index >> 3, dev, | ||
545 | + p->epnum, dirs[p->epdir], p->len); | ||
546 | + assert(p->async == DWC2_ASYNC_INFLIGHT); | ||
547 | + | ||
548 | + if (packet->status == USB_RET_REMOVE_FROM_QUEUE) { | ||
549 | + usb_cancel_packet(packet); | ||
550 | + usb_packet_cleanup(packet); | ||
551 | + return; | ||
552 | + } | ||
553 | + | ||
554 | + dwc2_handle_packet(s, p->devadr, dev, ep, p->index, false); | ||
555 | + | ||
556 | + p->async = DWC2_ASYNC_FINISHED; | ||
557 | + qemu_bh_schedule(s->async_bh); | ||
558 | +} | ||
559 | + | ||
560 | +static USBPortOps dwc2_port_ops = { | ||
561 | + .attach = dwc2_attach, | ||
562 | + .detach = dwc2_detach, | ||
563 | + .child_detach = dwc2_child_detach, | ||
564 | + .wakeup = dwc2_wakeup, | ||
565 | + .complete = dwc2_async_packet_complete, | ||
566 | +}; | ||
567 | + | ||
568 | +static uint32_t dwc2_get_frame_remaining(DWC2State *s) | ||
569 | +{ | ||
570 | + uint32_t fr = 0; | ||
571 | + int64_t tks; | ||
572 | + | ||
573 | + tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->sof_time; | ||
574 | + if (tks < 0) { | ||
575 | + tks = 0; | ||
576 | + } | ||
577 | + | ||
578 | + /* avoid muldiv if possible */ | ||
579 | + if (tks >= s->usb_frame_time) { | ||
580 | + goto out; | ||
581 | + } | ||
582 | + if (tks < s->usb_bit_time) { | ||
583 | + fr = s->fi; | ||
584 | + goto out; | ||
585 | + } | ||
586 | + | ||
587 | + /* tks = number of ns since SOF, divided by 83 (fs) or 10 (hs) */ | ||
588 | + tks = tks / s->usb_bit_time; | ||
589 | + if (tks >= (int64_t)s->fi) { | ||
590 | + goto out; | ||
591 | + } | ||
592 | + | ||
593 | + /* remaining = frame interval minus tks */ | ||
594 | + fr = (uint32_t)((int64_t)s->fi - tks); | ||
595 | + | ||
596 | +out: | ||
597 | + return fr; | ||
598 | +} | ||
599 | + | ||
600 | +static void dwc2_work_bh(void *opaque) | ||
601 | +{ | ||
602 | + DWC2State *s = opaque; | ||
603 | + DWC2Packet *p; | ||
604 | + USBDevice *dev; | ||
605 | + USBEndpoint *ep; | ||
606 | + int64_t t_now, expire_time; | ||
607 | + int chan; | ||
608 | + bool found = false; | ||
609 | + | ||
610 | + trace_usb_dwc2_work_bh(); | ||
611 | + if (s->working) { | ||
612 | + return; | ||
613 | + } | ||
614 | + s->working = true; | ||
615 | + | ||
616 | + t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
617 | + chan = s->next_chan; | ||
618 | + | ||
619 | + do { | ||
620 | + p = &s->packet[chan]; | ||
621 | + if (p->needs_service) { | ||
622 | + dev = dwc2_find_device(s, p->devadr); | ||
623 | + ep = usb_ep_get(dev, p->pid, p->epnum); | ||
624 | + trace_usb_dwc2_work_bh_service(s->next_chan, chan, dev, p->epnum); | ||
625 | + dwc2_handle_packet(s, p->devadr, dev, ep, p->index, true); | ||
626 | + found = true; | ||
627 | + } | ||
628 | + if (++chan == DWC2_NB_CHAN) { | ||
629 | + chan = 0; | ||
630 | + } | ||
631 | + if (found) { | ||
632 | + s->next_chan = chan; | ||
633 | + trace_usb_dwc2_work_bh_next(chan); | ||
634 | + } | ||
635 | + } while (chan != s->next_chan); | ||
636 | + | ||
637 | + if (found) { | ||
638 | + expire_time = t_now + NANOSECONDS_PER_SECOND / 4000; | ||
639 | + timer_mod(s->frame_timer, expire_time); | ||
640 | + } | ||
641 | + s->working = false; | ||
642 | +} | ||
643 | + | ||
644 | +static void dwc2_enable_chan(DWC2State *s, uint32_t index) | ||
645 | +{ | ||
646 | + USBDevice *dev; | ||
647 | + USBEndpoint *ep; | ||
648 | + uint32_t hcchar; | ||
649 | + uint32_t hctsiz; | ||
650 | + uint32_t devadr, epnum, epdir, eptype, pid, len; | ||
651 | + DWC2Packet *p; | ||
652 | + | ||
653 | + assert((index >> 3) < DWC2_NB_CHAN); | ||
654 | + p = &s->packet[index >> 3]; | ||
655 | + hcchar = s->hreg1[index]; | ||
656 | + hctsiz = s->hreg1[index + 4]; | ||
657 | + devadr = get_field(hcchar, HCCHAR_DEVADDR); | ||
658 | + epnum = get_field(hcchar, HCCHAR_EPNUM); | ||
659 | + epdir = get_bit(hcchar, HCCHAR_EPDIR); | ||
660 | + eptype = get_field(hcchar, HCCHAR_EPTYPE); | ||
661 | + pid = get_field(hctsiz, TSIZ_SC_MC_PID); | ||
662 | + len = get_field(hctsiz, TSIZ_XFERSIZE); | ||
663 | + | ||
664 | + dev = dwc2_find_device(s, devadr); | ||
665 | + | ||
666 | + trace_usb_dwc2_enable_chan(index >> 3, dev, &p->packet, epnum); | ||
667 | + if (dev == NULL) { | ||
668 | + return; | ||
669 | + } | ||
670 | + | ||
671 | + if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) { | ||
672 | + pid = USB_TOKEN_SETUP; | ||
673 | + } else { | ||
674 | + pid = epdir ? USB_TOKEN_IN : USB_TOKEN_OUT; | ||
675 | + } | ||
676 | + | ||
677 | + ep = usb_ep_get(dev, pid, epnum); | ||
678 | + | ||
679 | + /* | ||
680 | + * Hack: Networking doesn't like us delivering large transfers, it kind | ||
681 | + * of works but the latency is horrible. So if the transfer is <= the mtu | ||
682 | + * size, we take that as a hint that this might be a network transfer, | ||
683 | + * and do the transfer packet-by-packet. | ||
684 | + */ | ||
685 | + if (len > 1536) { | ||
686 | + p->small = false; | ||
687 | + } else { | ||
688 | + p->small = true; | ||
689 | + } | ||
690 | + | ||
691 | + dwc2_handle_packet(s, devadr, dev, ep, index, true); | ||
692 | + qemu_bh_schedule(s->async_bh); | ||
693 | +} | ||
694 | + | ||
695 | +static const char *glbregnm[] = { | ||
696 | + "GOTGCTL ", "GOTGINT ", "GAHBCFG ", "GUSBCFG ", "GRSTCTL ", | ||
697 | + "GINTSTS ", "GINTMSK ", "GRXSTSR ", "GRXSTSP ", "GRXFSIZ ", | ||
698 | + "GNPTXFSIZ", "GNPTXSTS ", "GI2CCTL ", "GPVNDCTL ", "GGPIO ", | ||
699 | + "GUID ", "GSNPSID ", "GHWCFG1 ", "GHWCFG2 ", "GHWCFG3 ", | ||
700 | + "GHWCFG4 ", "GLPMCFG ", "GPWRDN ", "GDFIFOCFG", "GADPCTL ", | ||
701 | + "GREFCLK ", "GINTMSK2 ", "GINTSTS2 " | ||
702 | +}; | ||
703 | + | ||
704 | +static uint64_t dwc2_glbreg_read(void *ptr, hwaddr addr, int index, | ||
705 | + unsigned size) | ||
706 | +{ | ||
707 | + DWC2State *s = ptr; | ||
708 | + uint32_t val; | ||
709 | + | ||
710 | + assert(addr <= GINTSTS2); | ||
711 | + val = s->glbreg[index]; | ||
712 | + | ||
713 | + switch (addr) { | ||
714 | + case GRSTCTL: | ||
715 | + /* clear any self-clearing bits that were set */ | ||
716 | + val &= ~(GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH | GRSTCTL_IN_TKNQ_FLSH | | ||
717 | + GRSTCTL_FRMCNTRRST | GRSTCTL_HSFTRST | GRSTCTL_CSFTRST); | ||
718 | + s->glbreg[index] = val; | ||
719 | + break; | ||
720 | + default: | ||
721 | + break; | ||
722 | + } | ||
723 | + | ||
724 | + trace_usb_dwc2_glbreg_read(addr, glbregnm[index], val); | ||
725 | + return val; | ||
726 | +} | ||
727 | + | ||
728 | +static void dwc2_glbreg_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
729 | + unsigned size) | ||
730 | +{ | ||
731 | + DWC2State *s = ptr; | ||
732 | + uint64_t orig = val; | ||
733 | + uint32_t *mmio; | ||
734 | + uint32_t old; | ||
735 | + int iflg = 0; | ||
736 | + | ||
737 | + assert(addr <= GINTSTS2); | ||
738 | + mmio = &s->glbreg[index]; | ||
739 | + old = *mmio; | ||
740 | + | ||
741 | + switch (addr) { | ||
742 | + case GOTGCTL: | ||
743 | + /* don't allow setting of read-only bits */ | ||
744 | + val &= ~(GOTGCTL_MULT_VALID_BC_MASK | GOTGCTL_BSESVLD | | ||
745 | + GOTGCTL_ASESVLD | GOTGCTL_DBNC_SHORT | GOTGCTL_CONID_B | | ||
746 | + GOTGCTL_HSTNEGSCS | GOTGCTL_SESREQSCS); | ||
747 | + /* don't allow clearing of read-only bits */ | ||
748 | + val |= old & (GOTGCTL_MULT_VALID_BC_MASK | GOTGCTL_BSESVLD | | ||
749 | + GOTGCTL_ASESVLD | GOTGCTL_DBNC_SHORT | GOTGCTL_CONID_B | | ||
750 | + GOTGCTL_HSTNEGSCS | GOTGCTL_SESREQSCS); | ||
751 | + break; | ||
752 | + case GAHBCFG: | ||
753 | + if ((val & GAHBCFG_GLBL_INTR_EN) && !(old & GAHBCFG_GLBL_INTR_EN)) { | ||
754 | + iflg = 1; | ||
755 | + } | ||
756 | + break; | ||
757 | + case GRSTCTL: | ||
758 | + val |= GRSTCTL_AHBIDLE; | ||
759 | + val &= ~GRSTCTL_DMAREQ; | ||
760 | + if (!(old & GRSTCTL_TXFFLSH) && (val & GRSTCTL_TXFFLSH)) { | ||
761 | + /* TODO - TX fifo flush */ | ||
762 | + qemu_log_mask(LOG_UNIMP, "Tx FIFO flush not implemented\n"); | ||
763 | + } | ||
764 | + if (!(old & GRSTCTL_RXFFLSH) && (val & GRSTCTL_RXFFLSH)) { | ||
765 | + /* TODO - RX fifo flush */ | ||
766 | + qemu_log_mask(LOG_UNIMP, "Rx FIFO flush not implemented\n"); | ||
767 | + } | ||
768 | + if (!(old & GRSTCTL_IN_TKNQ_FLSH) && (val & GRSTCTL_IN_TKNQ_FLSH)) { | ||
769 | + /* TODO - device IN token queue flush */ | ||
770 | + qemu_log_mask(LOG_UNIMP, "Token queue flush not implemented\n"); | ||
771 | + } | ||
772 | + if (!(old & GRSTCTL_FRMCNTRRST) && (val & GRSTCTL_FRMCNTRRST)) { | ||
773 | + /* TODO - host frame counter reset */ | ||
774 | + qemu_log_mask(LOG_UNIMP, "Frame counter reset not implemented\n"); | ||
775 | + } | ||
776 | + if (!(old & GRSTCTL_HSFTRST) && (val & GRSTCTL_HSFTRST)) { | ||
777 | + /* TODO - host soft reset */ | ||
778 | + qemu_log_mask(LOG_UNIMP, "Host soft reset not implemented\n"); | ||
779 | + } | ||
780 | + if (!(old & GRSTCTL_CSFTRST) && (val & GRSTCTL_CSFTRST)) { | ||
781 | + /* TODO - core soft reset */ | ||
782 | + qemu_log_mask(LOG_UNIMP, "Core soft reset not implemented\n"); | ||
783 | + } | ||
784 | + /* don't allow clearing of self-clearing bits */ | ||
785 | + val |= old & (GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH | | ||
786 | + GRSTCTL_IN_TKNQ_FLSH | GRSTCTL_FRMCNTRRST | | ||
787 | + GRSTCTL_HSFTRST | GRSTCTL_CSFTRST); | ||
788 | + break; | ||
789 | + case GINTSTS: | ||
790 | + /* clear the write-1-to-clear bits */ | ||
791 | + val |= ~old; | ||
792 | + val = ~val; | ||
793 | + /* don't allow clearing of read-only bits */ | ||
794 | + val |= old & (GINTSTS_PTXFEMP | GINTSTS_HCHINT | GINTSTS_PRTINT | | ||
795 | + GINTSTS_OEPINT | GINTSTS_IEPINT | GINTSTS_GOUTNAKEFF | | ||
796 | + GINTSTS_GINNAKEFF | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL | | ||
797 | + GINTSTS_OTGINT | GINTSTS_CURMODE_HOST); | ||
798 | + iflg = 1; | ||
799 | + break; | ||
800 | + case GINTMSK: | ||
801 | + iflg = 1; | ||
802 | + break; | ||
803 | + default: | ||
804 | + break; | ||
805 | + } | ||
806 | + | ||
807 | + trace_usb_dwc2_glbreg_write(addr, glbregnm[index], orig, old, val); | ||
808 | + *mmio = val; | ||
809 | + | ||
810 | + if (iflg) { | ||
811 | + dwc2_update_irq(s); | ||
812 | + } | ||
813 | +} | ||
814 | + | ||
815 | +static uint64_t dwc2_fszreg_read(void *ptr, hwaddr addr, int index, | ||
816 | + unsigned size) | ||
817 | +{ | ||
818 | + DWC2State *s = ptr; | ||
819 | + uint32_t val; | ||
820 | + | ||
821 | + assert(addr == HPTXFSIZ); | ||
822 | + val = s->fszreg[index]; | ||
823 | + | ||
824 | + trace_usb_dwc2_fszreg_read(addr, val); | ||
825 | + return val; | ||
826 | +} | ||
827 | + | ||
828 | +static void dwc2_fszreg_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
829 | + unsigned size) | ||
830 | +{ | ||
831 | + DWC2State *s = ptr; | ||
832 | + uint64_t orig = val; | ||
833 | + uint32_t *mmio; | ||
834 | + uint32_t old; | ||
835 | + | ||
836 | + assert(addr == HPTXFSIZ); | ||
837 | + mmio = &s->fszreg[index]; | ||
838 | + old = *mmio; | ||
839 | + | ||
840 | + trace_usb_dwc2_fszreg_write(addr, orig, old, val); | ||
841 | + *mmio = val; | ||
842 | +} | ||
843 | + | ||
844 | +static const char *hreg0nm[] = { | ||
845 | + "HCFG ", "HFIR ", "HFNUM ", "<rsvd> ", "HPTXSTS ", | ||
846 | + "HAINT ", "HAINTMSK ", "HFLBADDR ", "<rsvd> ", "<rsvd> ", | ||
847 | + "<rsvd> ", "<rsvd> ", "<rsvd> ", "<rsvd> ", "<rsvd> ", | ||
848 | + "<rsvd> ", "HPRT0 " | ||
849 | +}; | ||
850 | + | ||
851 | +static uint64_t dwc2_hreg0_read(void *ptr, hwaddr addr, int index, | ||
852 | + unsigned size) | ||
853 | +{ | ||
854 | + DWC2State *s = ptr; | ||
855 | + uint32_t val; | ||
856 | + | ||
857 | + assert(addr >= HCFG && addr <= HPRT0); | ||
858 | + val = s->hreg0[index]; | ||
859 | + | ||
860 | + switch (addr) { | ||
861 | + case HFNUM: | ||
862 | + val = (dwc2_get_frame_remaining(s) << HFNUM_FRREM_SHIFT) | | ||
863 | + (s->hfnum << HFNUM_FRNUM_SHIFT); | ||
864 | + break; | ||
865 | + default: | ||
866 | + break; | ||
867 | + } | ||
868 | + | ||
869 | + trace_usb_dwc2_hreg0_read(addr, hreg0nm[index], val); | ||
870 | + return val; | ||
871 | +} | ||
872 | + | ||
873 | +static void dwc2_hreg0_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
874 | + unsigned size) | ||
875 | +{ | ||
876 | + DWC2State *s = ptr; | ||
877 | + USBDevice *dev = s->uport.dev; | ||
878 | + uint64_t orig = val; | ||
879 | + uint32_t *mmio; | ||
880 | + uint32_t tval, told, old; | ||
881 | + int prst = 0; | ||
882 | + int iflg = 0; | ||
883 | + | ||
884 | + assert(addr >= HCFG && addr <= HPRT0); | ||
885 | + mmio = &s->hreg0[index]; | ||
886 | + old = *mmio; | ||
887 | + | ||
888 | + switch (addr) { | ||
889 | + case HFIR: | ||
890 | + break; | ||
891 | + case HFNUM: | ||
892 | + case HPTXSTS: | ||
893 | + case HAINT: | ||
894 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write to read-only register\n", | ||
895 | + __func__); | ||
896 | + return; | ||
897 | + case HAINTMSK: | ||
898 | + val &= 0xffff; | ||
899 | + break; | ||
900 | + case HPRT0: | ||
901 | + /* don't allow clearing of read-only bits */ | ||
902 | + val |= old & (HPRT0_SPD_MASK | HPRT0_LNSTS_MASK | HPRT0_OVRCURRACT | | ||
903 | + HPRT0_CONNSTS); | ||
904 | + /* don't allow clearing of self-clearing bits */ | ||
905 | + val |= old & (HPRT0_SUSP | HPRT0_RES); | ||
906 | + /* don't allow setting of self-setting bits */ | ||
907 | + if (!(old & HPRT0_ENA) && (val & HPRT0_ENA)) { | ||
908 | + val &= ~HPRT0_ENA; | ||
909 | + } | ||
910 | + /* clear the write-1-to-clear bits */ | ||
911 | + tval = val & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
912 | + HPRT0_CONNDET); | ||
913 | + told = old & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
914 | + HPRT0_CONNDET); | ||
915 | + tval |= ~told; | ||
916 | + tval = ~tval; | ||
917 | + tval &= (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
918 | + HPRT0_CONNDET); | ||
919 | + val &= ~(HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
920 | + HPRT0_CONNDET); | ||
921 | + val |= tval; | ||
922 | + if (!(val & HPRT0_RST) && (old & HPRT0_RST)) { | ||
923 | + if (dev && dev->attached) { | ||
924 | + val |= HPRT0_ENA | HPRT0_ENACHG; | ||
925 | + prst = 1; | ||
926 | + } | ||
927 | + } | ||
928 | + if (val & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_CONNDET)) { | ||
929 | + iflg = 1; | ||
930 | + } else { | ||
931 | + iflg = -1; | ||
932 | + } | ||
933 | + break; | ||
934 | + default: | ||
935 | + break; | ||
936 | + } | ||
937 | + | ||
938 | + if (prst) { | ||
939 | + trace_usb_dwc2_hreg0_write(addr, hreg0nm[index], orig, old, | ||
940 | + val & ~HPRT0_CONNDET); | ||
941 | + trace_usb_dwc2_hreg0_action("call usb_port_reset"); | ||
942 | + usb_port_reset(&s->uport); | ||
943 | + val &= ~HPRT0_CONNDET; | ||
944 | + } else { | ||
945 | + trace_usb_dwc2_hreg0_write(addr, hreg0nm[index], orig, old, val); | ||
946 | + } | ||
947 | + | ||
948 | + *mmio = val; | ||
949 | + | ||
950 | + if (iflg > 0) { | ||
951 | + trace_usb_dwc2_hreg0_action("enable PRTINT"); | ||
952 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
953 | + } else if (iflg < 0) { | ||
954 | + trace_usb_dwc2_hreg0_action("disable PRTINT"); | ||
955 | + dwc2_lower_global_irq(s, GINTSTS_PRTINT); | ||
956 | + } | ||
957 | +} | ||
958 | + | ||
959 | +static const char *hreg1nm[] = { | ||
960 | + "HCCHAR ", "HCSPLT ", "HCINT ", "HCINTMSK", "HCTSIZ ", "HCDMA ", | ||
961 | + "<rsvd> ", "HCDMAB " | ||
962 | +}; | ||
963 | + | ||
964 | +static uint64_t dwc2_hreg1_read(void *ptr, hwaddr addr, int index, | ||
965 | + unsigned size) | ||
966 | +{ | ||
967 | + DWC2State *s = ptr; | ||
968 | + uint32_t val; | ||
969 | + | ||
970 | + assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1)); | ||
971 | + val = s->hreg1[index]; | ||
972 | + | ||
973 | + trace_usb_dwc2_hreg1_read(addr, hreg1nm[index & 7], addr >> 5, val); | ||
974 | + return val; | ||
975 | +} | ||
976 | + | ||
977 | +static void dwc2_hreg1_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
978 | + unsigned size) | ||
979 | +{ | ||
980 | + DWC2State *s = ptr; | ||
981 | + uint64_t orig = val; | ||
982 | + uint32_t *mmio; | ||
983 | + uint32_t old; | ||
984 | + int iflg = 0; | ||
985 | + int enflg = 0; | ||
986 | + int disflg = 0; | ||
987 | + | ||
988 | + assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1)); | ||
989 | + mmio = &s->hreg1[index]; | ||
990 | + old = *mmio; | ||
991 | + | ||
992 | + switch (HSOTG_REG(0x500) + (addr & 0x1c)) { | ||
993 | + case HCCHAR(0): | ||
994 | + if ((val & HCCHAR_CHDIS) && !(old & HCCHAR_CHDIS)) { | ||
995 | + val &= ~(HCCHAR_CHENA | HCCHAR_CHDIS); | ||
996 | + disflg = 1; | ||
997 | + } else { | ||
998 | + val |= old & HCCHAR_CHDIS; | ||
999 | + if ((val & HCCHAR_CHENA) && !(old & HCCHAR_CHENA)) { | ||
1000 | + val &= ~HCCHAR_CHDIS; | ||
1001 | + enflg = 1; | ||
1002 | + } else { | ||
1003 | + val |= old & HCCHAR_CHENA; | ||
1004 | + } | ||
1005 | + } | ||
1006 | + break; | ||
1007 | + case HCINT(0): | ||
1008 | + /* clear the write-1-to-clear bits */ | ||
1009 | + val |= ~old; | ||
1010 | + val = ~val; | ||
1011 | + val &= ~HCINTMSK_RESERVED14_31; | ||
1012 | + iflg = 1; | ||
1013 | + break; | ||
1014 | + case HCINTMSK(0): | ||
1015 | + val &= ~HCINTMSK_RESERVED14_31; | ||
1016 | + iflg = 1; | ||
1017 | + break; | ||
1018 | + case HCDMAB(0): | ||
1019 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write to read-only register\n", | ||
1020 | + __func__); | ||
1021 | + return; | ||
1022 | + default: | ||
1023 | + break; | ||
1024 | + } | ||
1025 | + | ||
1026 | + trace_usb_dwc2_hreg1_write(addr, hreg1nm[index & 7], index >> 3, orig, | ||
1027 | + old, val); | ||
1028 | + *mmio = val; | ||
1029 | + | ||
1030 | + if (disflg) { | ||
1031 | + /* set ChHltd in HCINT */ | ||
1032 | + s->hreg1[(index & ~7) + 2] |= HCINTMSK_CHHLTD; | ||
1033 | + iflg = 1; | ||
1034 | + } | ||
1035 | + | ||
1036 | + if (enflg) { | ||
1037 | + dwc2_enable_chan(s, index & ~7); | ||
1038 | + } | ||
1039 | + | ||
1040 | + if (iflg) { | ||
1041 | + dwc2_update_hc_irq(s, index & ~7); | ||
1042 | + } | ||
1043 | +} | ||
1044 | + | ||
1045 | +static const char *pcgregnm[] = { | ||
1046 | + "PCGCTL ", "PCGCCTL1 " | ||
1047 | +}; | ||
1048 | + | ||
1049 | +static uint64_t dwc2_pcgreg_read(void *ptr, hwaddr addr, int index, | ||
1050 | + unsigned size) | ||
1051 | +{ | ||
1052 | + DWC2State *s = ptr; | ||
1053 | + uint32_t val; | ||
1054 | + | ||
1055 | + assert(addr >= PCGCTL && addr <= PCGCCTL1); | ||
1056 | + val = s->pcgreg[index]; | ||
1057 | + | ||
1058 | + trace_usb_dwc2_pcgreg_read(addr, pcgregnm[index], val); | ||
1059 | + return val; | ||
1060 | +} | ||
1061 | + | ||
1062 | +static void dwc2_pcgreg_write(void *ptr, hwaddr addr, int index, | ||
1063 | + uint64_t val, unsigned size) | ||
1064 | +{ | ||
1065 | + DWC2State *s = ptr; | ||
1066 | + uint64_t orig = val; | ||
1067 | + uint32_t *mmio; | ||
1068 | + uint32_t old; | ||
1069 | + | ||
1070 | + assert(addr >= PCGCTL && addr <= PCGCCTL1); | ||
1071 | + mmio = &s->pcgreg[index]; | ||
1072 | + old = *mmio; | ||
1073 | + | ||
1074 | + trace_usb_dwc2_pcgreg_write(addr, pcgregnm[index], orig, old, val); | ||
1075 | + *mmio = val; | ||
1076 | +} | ||
1077 | + | ||
1078 | +static uint64_t dwc2_hsotg_read(void *ptr, hwaddr addr, unsigned size) | ||
1079 | +{ | ||
1080 | + uint64_t val; | ||
1081 | + | ||
1082 | + switch (addr) { | ||
1083 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | ||
1084 | + val = dwc2_glbreg_read(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, size); | ||
1085 | + break; | ||
1086 | + case HSOTG_REG(0x100): | ||
1087 | + val = dwc2_fszreg_read(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, size); | ||
1088 | + break; | ||
1089 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | ||
1090 | + /* Gadget-mode registers, just return 0 for now */ | ||
1091 | + val = 0; | ||
1092 | + break; | ||
1093 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | ||
1094 | + val = dwc2_hreg0_read(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, size); | ||
1095 | + break; | ||
1096 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | ||
1097 | + val = dwc2_hreg1_read(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, size); | ||
1098 | + break; | ||
1099 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | ||
1100 | + /* Gadget-mode registers, just return 0 for now */ | ||
1101 | + val = 0; | ||
1102 | + break; | ||
1103 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | ||
1104 | + val = dwc2_pcgreg_read(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, size); | ||
1105 | + break; | ||
1106 | + default: | ||
1107 | + g_assert_not_reached(); | ||
1108 | + } | ||
1109 | + | ||
1110 | + return val; | ||
1111 | +} | ||
1112 | + | ||
1113 | +static void dwc2_hsotg_write(void *ptr, hwaddr addr, uint64_t val, | ||
1114 | + unsigned size) | ||
1115 | +{ | ||
1116 | + switch (addr) { | ||
1117 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | ||
1118 | + dwc2_glbreg_write(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, val, size); | ||
1119 | + break; | ||
1120 | + case HSOTG_REG(0x100): | ||
1121 | + dwc2_fszreg_write(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, val, size); | ||
1122 | + break; | ||
1123 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | ||
1124 | + /* Gadget-mode registers, do nothing for now */ | ||
1125 | + break; | ||
1126 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | ||
1127 | + dwc2_hreg0_write(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, val, size); | ||
1128 | + break; | ||
1129 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | ||
1130 | + dwc2_hreg1_write(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, val, size); | ||
1131 | + break; | ||
1132 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | ||
1133 | + /* Gadget-mode registers, do nothing for now */ | ||
1134 | + break; | ||
1135 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | ||
1136 | + dwc2_pcgreg_write(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, val, size); | ||
1137 | + break; | ||
1138 | + default: | ||
1139 | + g_assert_not_reached(); | ||
1140 | + } | ||
1141 | +} | ||
1142 | + | ||
1143 | +static const MemoryRegionOps dwc2_mmio_hsotg_ops = { | ||
1144 | + .read = dwc2_hsotg_read, | ||
1145 | + .write = dwc2_hsotg_write, | ||
1146 | + .impl.min_access_size = 4, | ||
1147 | + .impl.max_access_size = 4, | ||
1148 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1149 | +}; | ||
1150 | + | ||
1151 | +static uint64_t dwc2_hreg2_read(void *ptr, hwaddr addr, unsigned size) | ||
1152 | +{ | ||
1153 | + /* TODO - implement FIFOs to support slave mode */ | ||
1154 | + trace_usb_dwc2_hreg2_read(addr, addr >> 12, 0); | ||
1155 | + qemu_log_mask(LOG_UNIMP, "FIFO read not implemented\n"); | ||
1156 | + return 0; | ||
1157 | +} | ||
1158 | + | ||
1159 | +static void dwc2_hreg2_write(void *ptr, hwaddr addr, uint64_t val, | ||
1160 | + unsigned size) | ||
1161 | +{ | ||
1162 | + uint64_t orig = val; | ||
1163 | + | ||
1164 | + /* TODO - implement FIFOs to support slave mode */ | ||
1165 | + trace_usb_dwc2_hreg2_write(addr, addr >> 12, orig, 0, val); | ||
1166 | + qemu_log_mask(LOG_UNIMP, "FIFO write not implemented\n"); | ||
1167 | +} | ||
1168 | + | ||
1169 | +static const MemoryRegionOps dwc2_mmio_hreg2_ops = { | ||
1170 | + .read = dwc2_hreg2_read, | ||
1171 | + .write = dwc2_hreg2_write, | ||
1172 | + .impl.min_access_size = 4, | ||
1173 | + .impl.max_access_size = 4, | ||
1174 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1175 | +}; | ||
1176 | + | ||
1177 | +static void dwc2_wakeup_endpoint(USBBus *bus, USBEndpoint *ep, | ||
1178 | + unsigned int stream) | ||
1179 | +{ | ||
1180 | + DWC2State *s = container_of(bus, DWC2State, bus); | ||
1181 | + | ||
1182 | + trace_usb_dwc2_wakeup_endpoint(ep, stream); | ||
1183 | + | ||
1184 | + /* TODO - do something here? */ | ||
1185 | + qemu_bh_schedule(s->async_bh); | ||
1186 | +} | ||
1187 | + | ||
1188 | +static USBBusOps dwc2_bus_ops = { | ||
1189 | + .wakeup_endpoint = dwc2_wakeup_endpoint, | ||
1190 | +}; | ||
1191 | + | ||
1192 | +static void dwc2_work_timer(void *opaque) | ||
1193 | +{ | ||
1194 | + DWC2State *s = opaque; | ||
1195 | + | ||
1196 | + trace_usb_dwc2_work_timer(); | ||
1197 | + qemu_bh_schedule(s->async_bh); | ||
1198 | +} | ||
1199 | + | ||
1200 | +static void dwc2_reset_enter(Object *obj, ResetType type) | ||
1201 | +{ | ||
1202 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1203 | + DWC2State *s = DWC2_USB(obj); | ||
1204 | + int i; | ||
1205 | + | ||
1206 | + trace_usb_dwc2_reset_enter(); | ||
1207 | + | ||
1208 | + if (c->parent_phases.enter) { | ||
1209 | + c->parent_phases.enter(obj, type); | ||
1210 | + } | ||
1211 | + | ||
1212 | + timer_del(s->frame_timer); | ||
1213 | + qemu_bh_cancel(s->async_bh); | ||
1214 | + | ||
1215 | + if (s->uport.dev && s->uport.dev->attached) { | ||
1216 | + usb_detach(&s->uport); | ||
1217 | + } | ||
1218 | + | ||
1219 | + dwc2_bus_stop(s); | ||
1220 | + | ||
1221 | + s->gotgctl = GOTGCTL_BSESVLD | GOTGCTL_ASESVLD | GOTGCTL_CONID_B; | ||
1222 | + s->gotgint = 0; | ||
1223 | + s->gahbcfg = 0; | ||
1224 | + s->gusbcfg = 5 << GUSBCFG_USBTRDTIM_SHIFT; | ||
1225 | + s->grstctl = GRSTCTL_AHBIDLE; | ||
1226 | + s->gintsts = GINTSTS_CONIDSTSCHNG | GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | | ||
1227 | + GINTSTS_CURMODE_HOST; | ||
1228 | + s->gintmsk = 0; | ||
1229 | + s->grxstsr = 0; | ||
1230 | + s->grxstsp = 0; | ||
1231 | + s->grxfsiz = 1024; | ||
1232 | + s->gnptxfsiz = 1024 << FIFOSIZE_DEPTH_SHIFT; | ||
1233 | + s->gnptxsts = (4 << FIFOSIZE_DEPTH_SHIFT) | 1024; | ||
1234 | + s->gi2cctl = GI2CCTL_I2CDATSE0 | GI2CCTL_ACK; | ||
1235 | + s->gpvndctl = 0; | ||
1236 | + s->ggpio = 0; | ||
1237 | + s->guid = 0; | ||
1238 | + s->gsnpsid = 0x4f54294a; | ||
1239 | + s->ghwcfg1 = 0; | ||
1240 | + s->ghwcfg2 = (8 << GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT) | | ||
1241 | + (4 << GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT) | | ||
1242 | + (4 << GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT) | | ||
1243 | + GHWCFG2_DYNAMIC_FIFO | | ||
1244 | + GHWCFG2_PERIO_EP_SUPPORTED | | ||
1245 | + ((DWC2_NB_CHAN - 1) << GHWCFG2_NUM_HOST_CHAN_SHIFT) | | ||
1246 | + (GHWCFG2_INT_DMA_ARCH << GHWCFG2_ARCHITECTURE_SHIFT) | | ||
1247 | + (GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST << GHWCFG2_OP_MODE_SHIFT); | ||
1248 | + s->ghwcfg3 = (4096 << GHWCFG3_DFIFO_DEPTH_SHIFT) | | ||
1249 | + (4 << GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT) | | ||
1250 | + (4 << GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT); | ||
1251 | + s->ghwcfg4 = 0; | ||
1252 | + s->glpmcfg = 0; | ||
1253 | + s->gpwrdn = GPWRDN_PWRDNRSTN; | ||
1254 | + s->gdfifocfg = 0; | ||
1255 | + s->gadpctl = 0; | ||
1256 | + s->grefclk = 0; | ||
1257 | + s->gintmsk2 = 0; | ||
1258 | + s->gintsts2 = 0; | ||
1259 | + | ||
1260 | + s->hptxfsiz = 500 << FIFOSIZE_DEPTH_SHIFT; | ||
1261 | + | ||
1262 | + s->hcfg = 2 << HCFG_RESVALID_SHIFT; | ||
1263 | + s->hfir = 60000; | ||
1264 | + s->hfnum = 0x3fff; | ||
1265 | + s->hptxsts = (16 << TXSTS_QSPCAVAIL_SHIFT) | 32768; | ||
1266 | + s->haint = 0; | ||
1267 | + s->haintmsk = 0; | ||
1268 | + s->hprt0 = 0; | ||
1269 | + | ||
1270 | + memset(s->hreg1, 0, sizeof(s->hreg1)); | ||
1271 | + memset(s->pcgreg, 0, sizeof(s->pcgreg)); | ||
1272 | + | ||
1273 | + s->sof_time = 0; | ||
1274 | + s->frame_number = 0; | ||
1275 | + s->fi = USB_FRMINTVL - 1; | ||
1276 | + s->next_chan = 0; | ||
1277 | + s->working = false; | ||
1278 | + | ||
1279 | + for (i = 0; i < DWC2_NB_CHAN; i++) { | ||
1280 | + s->packet[i].needs_service = false; | ||
1281 | + } | ||
1282 | +} | ||
1283 | + | ||
1284 | +static void dwc2_reset_hold(Object *obj) | ||
1285 | +{ | ||
1286 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1287 | + DWC2State *s = DWC2_USB(obj); | ||
1288 | + | ||
1289 | + trace_usb_dwc2_reset_hold(); | ||
1290 | + | ||
1291 | + if (c->parent_phases.hold) { | ||
1292 | + c->parent_phases.hold(obj); | ||
1293 | + } | ||
1294 | + | ||
1295 | + dwc2_update_irq(s); | ||
1296 | +} | ||
1297 | + | ||
1298 | +static void dwc2_reset_exit(Object *obj) | ||
1299 | +{ | ||
1300 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1301 | + DWC2State *s = DWC2_USB(obj); | ||
1302 | + | ||
1303 | + trace_usb_dwc2_reset_exit(); | ||
1304 | + | ||
1305 | + if (c->parent_phases.exit) { | ||
1306 | + c->parent_phases.exit(obj); | ||
1307 | + } | ||
1308 | + | ||
1309 | + s->hprt0 = HPRT0_PWR; | ||
1310 | + if (s->uport.dev && s->uport.dev->attached) { | ||
1311 | + usb_attach(&s->uport); | ||
1312 | + usb_device_reset(s->uport.dev); | ||
1313 | + } | ||
1314 | +} | ||
1315 | + | ||
1316 | +static void dwc2_realize(DeviceState *dev, Error **errp) | ||
1317 | +{ | ||
1318 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
1319 | + DWC2State *s = DWC2_USB(dev); | ||
1320 | + Object *obj; | ||
1321 | + Error *err = NULL; | ||
1322 | + | ||
1323 | + obj = object_property_get_link(OBJECT(dev), "dma-mr", &err); | ||
1324 | + if (err) { | ||
1325 | + error_setg(errp, "dwc2: required dma-mr link not found: %s", | ||
1326 | + error_get_pretty(err)); | ||
1327 | + return; | ||
1328 | + } | ||
1329 | + assert(obj != NULL); | ||
1330 | + | ||
1331 | + s->dma_mr = MEMORY_REGION(obj); | ||
1332 | + address_space_init(&s->dma_as, s->dma_mr, "dwc2"); | ||
1333 | + | ||
1334 | + usb_bus_new(&s->bus, sizeof(s->bus), &dwc2_bus_ops, dev); | ||
1335 | + usb_register_port(&s->bus, &s->uport, s, 0, &dwc2_port_ops, | ||
1336 | + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL | | ||
1337 | + (s->usb_version == 2 ? USB_SPEED_MASK_HIGH : 0)); | ||
1338 | + s->uport.dev = 0; | ||
1339 | + | ||
1340 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 1000; /* 1000000 */ | ||
1341 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_FS) { | ||
1342 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_FS; /* 83.3 */ | ||
1343 | + } else { | ||
1344 | + s->usb_bit_time = 1; | ||
1345 | + } | ||
1346 | + | ||
1347 | + s->fi = USB_FRMINTVL - 1; | ||
1348 | + s->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_frame_boundary, s); | ||
1349 | + s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_work_timer, s); | ||
1350 | + s->async_bh = qemu_bh_new(dwc2_work_bh, s); | ||
1351 | + | ||
1352 | + sysbus_init_irq(sbd, &s->irq); | ||
1353 | +} | ||
1354 | + | ||
1355 | +static void dwc2_init(Object *obj) | ||
1356 | +{ | ||
1357 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
1358 | + DWC2State *s = DWC2_USB(obj); | ||
1359 | + | ||
1360 | + memory_region_init(&s->container, obj, "dwc2", DWC2_MMIO_SIZE); | ||
1361 | + sysbus_init_mmio(sbd, &s->container); | ||
1362 | + | ||
1363 | + memory_region_init_io(&s->hsotg, obj, &dwc2_mmio_hsotg_ops, s, | ||
1364 | + "dwc2-io", 4 * KiB); | ||
1365 | + memory_region_add_subregion(&s->container, 0x0000, &s->hsotg); | ||
1366 | + | ||
1367 | + memory_region_init_io(&s->fifos, obj, &dwc2_mmio_hreg2_ops, s, | ||
1368 | + "dwc2-fifo", 64 * KiB); | ||
1369 | + memory_region_add_subregion(&s->container, 0x1000, &s->fifos); | ||
1370 | +} | ||
1371 | + | ||
1372 | +static const VMStateDescription vmstate_dwc2_state_packet = { | ||
1373 | + .name = "dwc2/packet", | ||
1374 | + .version_id = 1, | 454 | + .version_id = 1, |
1375 | + .minimum_version_id = 1, | 455 | + .minimum_version_id = 1, |
456 | + .needed = pmsav8r_needed, | ||
1376 | + .fields = (VMStateField[]) { | 457 | + .fields = (VMStateField[]) { |
1377 | + VMSTATE_UINT32(devadr, DWC2Packet), | 458 | + VMSTATE_VARRAY_UINT32(env.pmsav8.hprbar, ARMCPU, |
1378 | + VMSTATE_UINT32(epnum, DWC2Packet), | 459 | + pmsav8r_hdregion, 0, vmstate_info_uint32, uint32_t), |
1379 | + VMSTATE_UINT32(epdir, DWC2Packet), | 460 | + VMSTATE_VARRAY_UINT32(env.pmsav8.hprlar, ARMCPU, |
1380 | + VMSTATE_UINT32(mps, DWC2Packet), | 461 | + pmsav8r_hdregion, 0, vmstate_info_uint32, uint32_t), |
1381 | + VMSTATE_UINT32(pid, DWC2Packet), | ||
1382 | + VMSTATE_UINT32(index, DWC2Packet), | ||
1383 | + VMSTATE_UINT32(pcnt, DWC2Packet), | ||
1384 | + VMSTATE_UINT32(len, DWC2Packet), | ||
1385 | + VMSTATE_INT32(async, DWC2Packet), | ||
1386 | + VMSTATE_BOOL(small, DWC2Packet), | ||
1387 | + VMSTATE_BOOL(needs_service, DWC2Packet), | ||
1388 | + VMSTATE_END_OF_LIST() | 462 | + VMSTATE_END_OF_LIST() |
1389 | + }, | 463 | + }, |
1390 | +}; | 464 | +}; |
1391 | + | 465 | + |
1392 | +const VMStateDescription vmstate_dwc2_state = { | 466 | static const VMStateDescription vmstate_pmsav8 = { |
1393 | + .name = "dwc2", | 467 | .name = "cpu/pmsav8", |
1394 | + .version_id = 1, | 468 | .version_id = 1, |
1395 | + .minimum_version_id = 1, | 469 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pmsav8 = { |
1396 | + .fields = (VMStateField[]) { | 470 | VMSTATE_UINT32(env.pmsav8.mair0[M_REG_NS], ARMCPU), |
1397 | + VMSTATE_UINT32_ARRAY(glbreg, DWC2State, | 471 | VMSTATE_UINT32(env.pmsav8.mair1[M_REG_NS], ARMCPU), |
1398 | + DWC2_GLBREG_SIZE / sizeof(uint32_t)), | 472 | VMSTATE_END_OF_LIST() |
1399 | + VMSTATE_UINT32_ARRAY(fszreg, DWC2State, | 473 | + }, |
1400 | + DWC2_FSZREG_SIZE / sizeof(uint32_t)), | 474 | + .subsections = (const VMStateDescription * []) { |
1401 | + VMSTATE_UINT32_ARRAY(hreg0, DWC2State, | 475 | + &vmstate_pmsav8r, |
1402 | + DWC2_HREG0_SIZE / sizeof(uint32_t)), | 476 | + NULL |
1403 | + VMSTATE_UINT32_ARRAY(hreg1, DWC2State, | 477 | } |
1404 | + DWC2_HREG1_SIZE / sizeof(uint32_t)), | 478 | }; |
1405 | + VMSTATE_UINT32_ARRAY(pcgreg, DWC2State, | 479 | |
1406 | + DWC2_PCGREG_SIZE / sizeof(uint32_t)), | ||
1407 | + | ||
1408 | + VMSTATE_TIMER_PTR(eof_timer, DWC2State), | ||
1409 | + VMSTATE_TIMER_PTR(frame_timer, DWC2State), | ||
1410 | + VMSTATE_INT64(sof_time, DWC2State), | ||
1411 | + VMSTATE_INT64(usb_frame_time, DWC2State), | ||
1412 | + VMSTATE_INT64(usb_bit_time, DWC2State), | ||
1413 | + VMSTATE_UINT32(usb_version, DWC2State), | ||
1414 | + VMSTATE_UINT16(frame_number, DWC2State), | ||
1415 | + VMSTATE_UINT16(fi, DWC2State), | ||
1416 | + VMSTATE_UINT16(next_chan, DWC2State), | ||
1417 | + VMSTATE_BOOL(working, DWC2State), | ||
1418 | + | ||
1419 | + VMSTATE_STRUCT_ARRAY(packet, DWC2State, DWC2_NB_CHAN, 1, | ||
1420 | + vmstate_dwc2_state_packet, DWC2Packet), | ||
1421 | + VMSTATE_UINT8_2DARRAY(usb_buf, DWC2State, DWC2_NB_CHAN, | ||
1422 | + DWC2_MAX_XFER_SIZE), | ||
1423 | + | ||
1424 | + VMSTATE_END_OF_LIST() | ||
1425 | + } | ||
1426 | +}; | ||
1427 | + | ||
1428 | +static Property dwc2_usb_properties[] = { | ||
1429 | + DEFINE_PROP_UINT32("usb_version", DWC2State, usb_version, 2), | ||
1430 | + DEFINE_PROP_END_OF_LIST(), | ||
1431 | +}; | ||
1432 | + | ||
1433 | +static void dwc2_class_init(ObjectClass *klass, void *data) | ||
1434 | +{ | ||
1435 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
1436 | + DWC2Class *c = DWC2_CLASS(klass); | ||
1437 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
1438 | + | ||
1439 | + dc->realize = dwc2_realize; | ||
1440 | + dc->vmsd = &vmstate_dwc2_state; | ||
1441 | + set_bit(DEVICE_CATEGORY_USB, dc->categories); | ||
1442 | + device_class_set_props(dc, dwc2_usb_properties); | ||
1443 | + resettable_class_set_parent_phases(rc, dwc2_reset_enter, dwc2_reset_hold, | ||
1444 | + dwc2_reset_exit, &c->parent_phases); | ||
1445 | +} | ||
1446 | + | ||
1447 | +static const TypeInfo dwc2_usb_type_info = { | ||
1448 | + .name = TYPE_DWC2_USB, | ||
1449 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1450 | + .instance_size = sizeof(DWC2State), | ||
1451 | + .instance_init = dwc2_init, | ||
1452 | + .class_size = sizeof(DWC2Class), | ||
1453 | + .class_init = dwc2_class_init, | ||
1454 | +}; | ||
1455 | + | ||
1456 | +static void dwc2_usb_register_types(void) | ||
1457 | +{ | ||
1458 | + type_register_static(&dwc2_usb_type_info); | ||
1459 | +} | ||
1460 | + | ||
1461 | +type_init(dwc2_usb_register_types) | ||
1462 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | ||
1463 | index XXXXXXX..XXXXXXX 100644 | ||
1464 | --- a/hw/usb/Kconfig | ||
1465 | +++ b/hw/usb/Kconfig | ||
1466 | @@ -XXX,XX +XXX,XX @@ config USB_MUSB | ||
1467 | bool | ||
1468 | select USB | ||
1469 | |||
1470 | +config USB_DWC2 | ||
1471 | + bool | ||
1472 | + default y | ||
1473 | + select USB | ||
1474 | + | ||
1475 | config TUSB6010 | ||
1476 | bool | ||
1477 | select USB_MUSB | ||
1478 | diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs | ||
1479 | index XXXXXXX..XXXXXXX 100644 | ||
1480 | --- a/hw/usb/Makefile.objs | ||
1481 | +++ b/hw/usb/Makefile.objs | ||
1482 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o | ||
1483 | common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o | ||
1484 | common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o | ||
1485 | common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o | ||
1486 | +common-obj-$(CONFIG_USB_DWC2) += hcd-dwc2.o | ||
1487 | |||
1488 | common-obj-$(CONFIG_TUSB6010) += tusb6010.o | ||
1489 | common-obj-$(CONFIG_IMX) += chipidea.o | ||
1490 | diff --git a/hw/usb/trace-events b/hw/usb/trace-events | ||
1491 | index XXXXXXX..XXXXXXX 100644 | ||
1492 | --- a/hw/usb/trace-events | ||
1493 | +++ b/hw/usb/trace-events | ||
1494 | @@ -XXX,XX +XXX,XX @@ usb_xhci_xfer_error(void *xfer, uint32_t ret) "%p: ret %d" | ||
1495 | usb_xhci_unimplemented(const char *item, int nr) "%s (0x%x)" | ||
1496 | usb_xhci_enforced_limit(const char *item) "%s" | ||
1497 | |||
1498 | +# hcd-dwc2.c | ||
1499 | +usb_dwc2_update_irq(uint32_t level) "level=%d" | ||
1500 | +usb_dwc2_raise_global_irq(uint32_t intr) "0x%08x" | ||
1501 | +usb_dwc2_lower_global_irq(uint32_t intr) "0x%08x" | ||
1502 | +usb_dwc2_raise_host_irq(uint32_t intr) "0x%04x" | ||
1503 | +usb_dwc2_lower_host_irq(uint32_t intr) "0x%04x" | ||
1504 | +usb_dwc2_sof(int64_t next) "next SOF %" PRId64 | ||
1505 | +usb_dwc2_bus_start(void) "start SOFs" | ||
1506 | +usb_dwc2_bus_stop(void) "stop SOFs" | ||
1507 | +usb_dwc2_find_device(uint8_t addr) "%d" | ||
1508 | +usb_dwc2_port_disabled(uint32_t pnum) "port %d disabled" | ||
1509 | +usb_dwc2_device_found(uint32_t pnum) "device found on port %d" | ||
1510 | +usb_dwc2_device_not_found(void) "device not found" | ||
1511 | +usb_dwc2_handle_packet(uint32_t chan, void *dev, void *pkt, uint32_t ep, const char *type, const char *dir, uint32_t mps, uint32_t len, uint32_t pcnt) "ch %d dev %p pkt %p ep %d type %s dir %s mps %d len %d pcnt %d" | ||
1512 | +usb_dwc2_memory_read(uint32_t addr, uint32_t len) "addr %d len %d" | ||
1513 | +usb_dwc2_packet_status(const char *status, uint32_t len) "status %s len %d" | ||
1514 | +usb_dwc2_packet_error(const char *status) "ERROR %s" | ||
1515 | +usb_dwc2_async_packet(void *pkt, uint32_t chan, void *dev, uint32_t ep, const char *dir, uint32_t len) "pkt %p ch %d dev %p ep %d %s len %d" | ||
1516 | +usb_dwc2_memory_write(uint32_t addr, uint32_t len) "addr %d len %d" | ||
1517 | +usb_dwc2_packet_done(const char *status, uint32_t actual, uint32_t len, uint32_t pcnt) "status %s actual %d len %d pcnt %d" | ||
1518 | +usb_dwc2_packet_next(const char *status, uint32_t len, uint32_t pcnt) "status %s len %d pcnt %d" | ||
1519 | +usb_dwc2_attach(void *port) "port %p" | ||
1520 | +usb_dwc2_attach_speed(const char *speed) "%s-speed device attached" | ||
1521 | +usb_dwc2_detach(void *port) "port %p" | ||
1522 | +usb_dwc2_child_detach(void *port, void *child) "port %p child %p" | ||
1523 | +usb_dwc2_wakeup(void *port) "port %p" | ||
1524 | +usb_dwc2_async_packet_complete(void *port, void *pkt, uint32_t chan, void *dev, uint32_t ep, const char *dir, uint32_t len) "port %p packet %p ch %d dev %p ep %d %s len %d" | ||
1525 | +usb_dwc2_work_bh(void) "" | ||
1526 | +usb_dwc2_work_bh_service(uint32_t first, uint32_t current, void *dev, uint32_t ep) "first %d servicing %d dev %p ep %d" | ||
1527 | +usb_dwc2_work_bh_next(uint32_t chan) "next %d" | ||
1528 | +usb_dwc2_enable_chan(uint32_t chan, void *dev, void *pkt, uint32_t ep) "ch %d dev %p pkt %p ep %d" | ||
1529 | +usb_dwc2_glbreg_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | ||
1530 | +usb_dwc2_glbreg_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1531 | +usb_dwc2_fszreg_read(uint64_t addr, uint32_t val) " 0x%04" PRIx64 " HPTXFSIZ val 0x%08x" | ||
1532 | +usb_dwc2_fszreg_write(uint64_t addr, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " HPTXFSIZ val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1533 | +usb_dwc2_hreg0_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | ||
1534 | +usb_dwc2_hreg0_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1535 | +usb_dwc2_hreg1_read(uint64_t addr, const char *reg, uint64_t chan, uint32_t val) " 0x%04" PRIx64 " %s%" PRId64 " val 0x%08x" | ||
1536 | +usb_dwc2_hreg1_write(uint64_t addr, const char *reg, uint64_t chan, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " %s%" PRId64 " val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1537 | +usb_dwc2_pcgreg_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | ||
1538 | +usb_dwc2_pcgreg_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1539 | +usb_dwc2_hreg2_read(uint64_t addr, uint64_t fifo, uint32_t val) " 0x%04" PRIx64 " FIFO%" PRId64 " val 0x%08x" | ||
1540 | +usb_dwc2_hreg2_write(uint64_t addr, uint64_t fifo, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " FIFO%" PRId64 " val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | ||
1541 | +usb_dwc2_hreg0_action(const char *s) "%s" | ||
1542 | +usb_dwc2_wakeup_endpoint(void *ep, uint32_t stream) "endp %p stream %d" | ||
1543 | +usb_dwc2_work_timer(void) "" | ||
1544 | +usb_dwc2_reset_enter(void) "=== RESET enter ===" | ||
1545 | +usb_dwc2_reset_hold(void) "=== RESET hold ===" | ||
1546 | +usb_dwc2_reset_exit(void) "=== RESET exit ===" | ||
1547 | + | ||
1548 | # desc.c | ||
1549 | usb_desc_device(int addr, int len, int ret) "dev %d query device, len %d, ret %d" | ||
1550 | usb_desc_device_qualifier(int addr, int len, int ret) "dev %d query device qualifier, len %d, ret %d" | ||
1551 | -- | 480 | -- |
1552 | 2.20.1 | 481 | 2.25.1 |
1553 | 482 | ||
1554 | 483 | diff view generated by jsdifflib |
1 | Convert the VQSHLU and QVSHL 2-reg-shift insns to decodetree. | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | These are the last of the simple shift-by-immediate insns. | 2 | |
3 | 3 | Add PMSAv8r translation. | |
4 | |||
5 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20221206102504.165775-7-tobias.roehmel@rwth-aachen.de | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200522145520.6778-5-peter.maydell@linaro.org | ||
7 | --- | 9 | --- |
8 | target/arm/neon-dp.decode | 15 +++++ | 10 | target/arm/ptw.c | 126 ++++++++++++++++++++++++++++++++++++++--------- |
9 | target/arm/translate-neon.inc.c | 108 +++++++++++++++++++++++++++++++ | 11 | 1 file changed, 104 insertions(+), 22 deletions(-) |
10 | target/arm/translate.c | 110 +------------------------------- | 12 | |
11 | 3 files changed, 126 insertions(+), 107 deletions(-) | 13 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
12 | |||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 15 | --- a/target/arm/ptw.c |
16 | +++ b/target/arm/neon-dp.decode | 16 | +++ b/target/arm/ptw.c |
17 | @@ -XXX,XX +XXX,XX @@ VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 17 | @@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx, |
18 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 18 | |
19 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 19 | if (arm_feature(env, ARM_FEATURE_M)) { |
20 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | 20 | return env->v7m.mpu_ctrl[is_secure] & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; |
21 | + | 21 | - } else { |
22 | +VQSHLU_64_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_d | 22 | - return regime_sctlr(env, mmu_idx) & SCTLR_BR; |
23 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_s | 23 | } |
24 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_h | 24 | + |
25 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_b | 25 | + if (mmu_idx == ARMMMUIdx_Stage2) { |
26 | + | 26 | + return false; |
27 | +VQSHL_S_64_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | 27 | + } |
28 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | 28 | + |
29 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | 29 | + return regime_sctlr(env, mmu_idx) & SCTLR_BR; |
30 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
31 | + | ||
32 | +VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
33 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
34 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
35 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
36 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate-neon.inc.c | ||
39 | +++ b/target/arm/translate-neon.inc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
41 | return do_vector_2sh(s, a, tcg_gen_gvec_shri); | ||
42 | } | ||
43 | } | 30 | } |
44 | + | 31 | |
45 | +static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | 32 | static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, |
46 | + NeonGenTwo64OpEnvFn *fn) | 33 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, |
34 | return !(result->f.prot & (1 << access_type)); | ||
35 | } | ||
36 | |||
37 | +static uint32_t *regime_rbar(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
38 | + uint32_t secure) | ||
47 | +{ | 39 | +{ |
48 | + /* | 40 | + if (regime_el(env, mmu_idx) == 2) { |
49 | + * 2-reg-and-shift operations, size == 3 case, where the | 41 | + return env->pmsav8.hprbar; |
50 | + * function needs to be passed cpu_env. | 42 | + } else { |
51 | + */ | 43 | + return env->pmsav8.rbar[secure]; |
52 | + TCGv_i64 constimm; | 44 | + } |
53 | + int pass; | ||
54 | + | ||
55 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
56 | + return false; | ||
57 | + } | ||
58 | + | ||
59 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
60 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
61 | + ((a->vd | a->vm) & 0x10)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + if ((a->vm | a->vd) & a->q) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + if (!vfp_access_check(s)) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + | ||
73 | + /* | ||
74 | + * To avoid excessive duplication of ops we implement shift | ||
75 | + * by immediate using the variable shift operations. | ||
76 | + */ | ||
77 | + constimm = tcg_const_i64(dup_const(a->size, a->shift)); | ||
78 | + | ||
79 | + for (pass = 0; pass < a->q + 1; pass++) { | ||
80 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
81 | + | ||
82 | + neon_load_reg64(tmp, a->vm + pass); | ||
83 | + fn(tmp, cpu_env, tmp, constimm); | ||
84 | + neon_store_reg64(tmp, a->vd + pass); | ||
85 | + } | ||
86 | + tcg_temp_free_i64(constimm); | ||
87 | + return true; | ||
88 | +} | 45 | +} |
89 | + | 46 | + |
90 | +static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 47 | +static uint32_t *regime_rlar(CPUARMState *env, ARMMMUIdx mmu_idx, |
91 | + NeonGenTwoOpEnvFn *fn) | 48 | + uint32_t secure) |
92 | +{ | 49 | +{ |
93 | + /* | 50 | + if (regime_el(env, mmu_idx) == 2) { |
94 | + * 2-reg-and-shift operations, size < 3 case, where the | 51 | + return env->pmsav8.hprlar; |
95 | + * helper needs to be passed cpu_env. | 52 | + } else { |
96 | + */ | 53 | + return env->pmsav8.rlar[secure]; |
97 | + TCGv_i32 constimm; | 54 | + } |
98 | + int pass; | ||
99 | + | ||
100 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + | ||
104 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
105 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
106 | + ((a->vd | a->vm) & 0x10)) { | ||
107 | + return false; | ||
108 | + } | ||
109 | + | ||
110 | + if ((a->vm | a->vd) & a->q) { | ||
111 | + return false; | ||
112 | + } | ||
113 | + | ||
114 | + if (!vfp_access_check(s)) { | ||
115 | + return true; | ||
116 | + } | ||
117 | + | ||
118 | + /* | ||
119 | + * To avoid excessive duplication of ops we implement shift | ||
120 | + * by immediate using the variable shift operations. | ||
121 | + */ | ||
122 | + constimm = tcg_const_i32(dup_const(a->size, a->shift)); | ||
123 | + | ||
124 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
125 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
126 | + fn(tmp, cpu_env, tmp, constimm); | ||
127 | + neon_store_reg(a->vd, pass, tmp); | ||
128 | + } | ||
129 | + tcg_temp_free_i32(constimm); | ||
130 | + return true; | ||
131 | +} | 55 | +} |
132 | + | 56 | + |
133 | +#define DO_2SHIFT_ENV(INSN, FUNC) \ | 57 | bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
134 | + static bool trans_##INSN##_64_2sh(DisasContext *s, arg_2reg_shift *a) \ | 58 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
135 | + { \ | 59 | bool secure, GetPhysAddrResult *result, |
136 | + return do_2shift_env_64(s, a, gen_helper_neon_##FUNC##64); \ | 60 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
137 | + } \ | 61 | bool hit = false; |
138 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | 62 | uint32_t addr_page_base = address & TARGET_PAGE_MASK; |
139 | + { \ | 63 | uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1); |
140 | + static NeonGenTwoOpEnvFn * const fns[] = { \ | 64 | + int region_counter; |
141 | + gen_helper_neon_##FUNC##8, \ | 65 | + |
142 | + gen_helper_neon_##FUNC##16, \ | 66 | + if (regime_el(env, mmu_idx) == 2) { |
143 | + gen_helper_neon_##FUNC##32, \ | 67 | + region_counter = cpu->pmsav8r_hdregion; |
144 | + }; \ | 68 | + } else { |
145 | + assert(a->size < ARRAY_SIZE(fns)); \ | 69 | + region_counter = cpu->pmsav7_dregion; |
146 | + return do_2shift_env_32(s, a, fns[a->size]); \ | 70 | + } |
147 | + } | 71 | |
148 | + | 72 | result->f.lg_page_size = TARGET_PAGE_BITS; |
149 | +DO_2SHIFT_ENV(VQSHLU, qshlu_s) | 73 | result->f.phys_addr = address; |
150 | +DO_2SHIFT_ENV(VQSHL_U, qshl_u) | 74 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
151 | +DO_2SHIFT_ENV(VQSHL_S, qshl_s) | 75 | *mregion = -1; |
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 76 | } |
153 | index XXXXXXX..XXXXXXX 100644 | 77 | |
154 | --- a/target/arm/translate.c | 78 | + if (mmu_idx == ARMMMUIdx_Stage2) { |
155 | +++ b/target/arm/translate.c | 79 | + fi->stage2 = true; |
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_rsb(int size, TCGv_i32 t0, TCGv_i32 t1) | 80 | + } |
157 | } | 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)); | ||
158 | } | 213 | } |
159 | 214 | ||
160 | -#define GEN_NEON_INTEGER_OP_ENV(name) do { \ | 215 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
161 | - switch ((size << 1) | u) { \ | 216 | cacheattrs1 = result->cacheattrs; |
162 | - case 0: \ | 217 | memset(result, 0, sizeof(*result)); |
163 | - gen_helper_neon_##name##_s8(tmp, cpu_env, tmp, tmp2); \ | 218 | |
164 | - break; \ | 219 | - ret = get_phys_addr_lpae(env, ptw, ipa, access_type, is_el0, result, fi); |
165 | - case 1: \ | 220 | + if (arm_feature(env, ARM_FEATURE_PMSA)) { |
166 | - gen_helper_neon_##name##_u8(tmp, cpu_env, tmp, tmp2); \ | 221 | + ret = get_phys_addr_pmsav8(env, ipa, access_type, |
167 | - break; \ | 222 | + ptw->in_mmu_idx, is_secure, result, fi); |
168 | - case 2: \ | 223 | + } else { |
169 | - gen_helper_neon_##name##_s16(tmp, cpu_env, tmp, tmp2); \ | 224 | + ret = get_phys_addr_lpae(env, ptw, ipa, access_type, |
170 | - break; \ | 225 | + is_el0, result, fi); |
171 | - case 3: \ | 226 | + } |
172 | - gen_helper_neon_##name##_u16(tmp, cpu_env, tmp, tmp2); \ | 227 | fi->s2addr = ipa; |
173 | - break; \ | 228 | |
174 | - case 4: \ | 229 | /* Combine the S1 and S2 perms. */ |
175 | - gen_helper_neon_##name##_s32(tmp, cpu_env, tmp, tmp2); \ | ||
176 | - break; \ | ||
177 | - case 5: \ | ||
178 | - gen_helper_neon_##name##_u32(tmp, cpu_env, tmp, tmp2); \ | ||
179 | - break; \ | ||
180 | - default: return 1; \ | ||
181 | - }} while (0) | ||
182 | - | ||
183 | static TCGv_i32 neon_load_scratch(int scratch) | ||
184 | { | ||
185 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
186 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
187 | int size; | ||
188 | int shift; | ||
189 | int pass; | ||
190 | - int count; | ||
191 | int u; | ||
192 | int vec_size; | ||
193 | uint32_t imm; | ||
194 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
195 | case 3: /* VRSRA */ | ||
196 | case 4: /* VSRI */ | ||
197 | case 5: /* VSHL, VSLI */ | ||
198 | + case 6: /* VQSHLU */ | ||
199 | + case 7: /* VQSHL */ | ||
200 | return 1; /* handled by decodetree */ | ||
201 | default: | ||
202 | break; | ||
203 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
204 | size--; | ||
205 | } | ||
206 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
207 | - if (op < 8) { | ||
208 | - /* Shift by immediate: | ||
209 | - VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */ | ||
210 | - if (q && ((rd | rm) & 1)) { | ||
211 | - return 1; | ||
212 | - } | ||
213 | - if (!u && (op == 4 || op == 6)) { | ||
214 | - return 1; | ||
215 | - } | ||
216 | - /* Right shifts are encoded as N - shift, where N is the | ||
217 | - element size in bits. */ | ||
218 | - if (op <= 4) { | ||
219 | - shift = shift - (1 << (size + 3)); | ||
220 | - } | ||
221 | - | ||
222 | - if (size == 3) { | ||
223 | - count = q + 1; | ||
224 | - } else { | ||
225 | - count = q ? 4: 2; | ||
226 | - } | ||
227 | - | ||
228 | - /* To avoid excessive duplication of ops we implement shift | ||
229 | - * by immediate using the variable shift operations. | ||
230 | - */ | ||
231 | - imm = dup_const(size, shift); | ||
232 | - | ||
233 | - for (pass = 0; pass < count; pass++) { | ||
234 | - if (size == 3) { | ||
235 | - neon_load_reg64(cpu_V0, rm + pass); | ||
236 | - tcg_gen_movi_i64(cpu_V1, imm); | ||
237 | - switch (op) { | ||
238 | - case 6: /* VQSHLU */ | ||
239 | - gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, | ||
240 | - cpu_V0, cpu_V1); | ||
241 | - break; | ||
242 | - case 7: /* VQSHL */ | ||
243 | - if (u) { | ||
244 | - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, | ||
245 | - cpu_V0, cpu_V1); | ||
246 | - } else { | ||
247 | - gen_helper_neon_qshl_s64(cpu_V0, cpu_env, | ||
248 | - cpu_V0, cpu_V1); | ||
249 | - } | ||
250 | - break; | ||
251 | - default: | ||
252 | - g_assert_not_reached(); | ||
253 | - } | ||
254 | - neon_store_reg64(cpu_V0, rd + pass); | ||
255 | - } else { /* size < 3 */ | ||
256 | - /* Operands in T0 and T1. */ | ||
257 | - tmp = neon_load_reg(rm, pass); | ||
258 | - tmp2 = tcg_temp_new_i32(); | ||
259 | - tcg_gen_movi_i32(tmp2, imm); | ||
260 | - switch (op) { | ||
261 | - case 6: /* VQSHLU */ | ||
262 | - switch (size) { | ||
263 | - case 0: | ||
264 | - gen_helper_neon_qshlu_s8(tmp, cpu_env, | ||
265 | - tmp, tmp2); | ||
266 | - break; | ||
267 | - case 1: | ||
268 | - gen_helper_neon_qshlu_s16(tmp, cpu_env, | ||
269 | - tmp, tmp2); | ||
270 | - break; | ||
271 | - case 2: | ||
272 | - gen_helper_neon_qshlu_s32(tmp, cpu_env, | ||
273 | - tmp, tmp2); | ||
274 | - break; | ||
275 | - default: | ||
276 | - abort(); | ||
277 | - } | ||
278 | - break; | ||
279 | - case 7: /* VQSHL */ | ||
280 | - GEN_NEON_INTEGER_OP_ENV(qshl); | ||
281 | - break; | ||
282 | - default: | ||
283 | - g_assert_not_reached(); | ||
284 | - } | ||
285 | - tcg_temp_free_i32(tmp2); | ||
286 | - neon_store_reg(rd, pass, tmp); | ||
287 | - } | ||
288 | - } /* for pass */ | ||
289 | - } else if (op < 10) { | ||
290 | + if (op < 10) { | ||
291 | /* Shift by immediate and narrow: | ||
292 | VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | ||
293 | int input_unsigned = (op == 8) ? !u : u; | ||
294 | -- | 230 | -- |
295 | 2.20.1 | 231 | 2.25.1 |
296 | 232 | ||
297 | 233 | diff view generated by jsdifflib |
1 | Convert the VSHLL and VMOVL insns from the 2-reg-shift group | 1 | From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> |
---|---|---|---|
2 | to decodetree. Since the loop always has two passes, we unroll | ||
3 | it to avoid the awkward reassignment of one TCGv to another. | ||
4 | 2 | ||
3 | All constants are taken from the ARM Cortex-R52 Processor TRM Revision: r1p3 | ||
4 | |||
5 | Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20221206102504.165775-8-tobias.roehmel@rwth-aachen.de | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200522145520.6778-8-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | target/arm/neon-dp.decode | 16 +++++++ | 10 | target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++ |
10 | target/arm/translate-neon.inc.c | 81 +++++++++++++++++++++++++++++++++ | 11 | 1 file changed, 42 insertions(+) |
11 | target/arm/translate.c | 46 +------------------ | ||
12 | 3 files changed, 99 insertions(+), 44 deletions(-) | ||
13 | 12 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 13 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 15 | --- a/target/arm/cpu_tcg.c |
17 | +++ b/target/arm/neon-dp.decode | 16 | +++ b/target/arm/cpu_tcg.c |
18 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 17 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) |
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 \ | 18 | define_arm_cp_regs(cpu, cortexr5_cp_reginfo); |
20 | shift=%neon_rshift_i3 | 19 | } |
21 | 20 | ||
22 | +# Long left shifts: again Q is part of opcode decode | 21 | +static void cortex_r52_initfn(Object *obj) |
23 | +@2reg_shll_s .... ... . . . 1 shift:5 .... .... 0 . . . .... \ | 22 | +{ |
24 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 q=0 | 23 | + ARMCPU *cpu = ARM_CPU(obj); |
25 | +@2reg_shll_h .... ... . . . 01 shift:4 .... .... 0 . . . .... \ | ||
26 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 | ||
27 | +@2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | ||
28 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | ||
29 | + | 24 | + |
30 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 25 | + set_feature(&cpu->env, ARM_FEATURE_V8); |
31 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 26 | + set_feature(&cpu->env, ARM_FEATURE_EL2); |
32 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 27 | + set_feature(&cpu->env, ARM_FEATURE_PMSA); |
33 | @@ -XXX,XX +XXX,XX @@ VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | 28 | + set_feature(&cpu->env, ARM_FEATURE_NEON); |
34 | VQRSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | 29 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
35 | VQRSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | 30 | + cpu->midr = 0x411fd133; /* r1p3 */ |
36 | VQRSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | 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 */ | ||
37 | + | 57 | + |
38 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | 58 | + cpu->pmsav7_dregion = 16; |
39 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | 59 | + cpu->pmsav8r_hdregion = 16; |
40 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
41 | + | ||
42 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
43 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
44 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
45 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate-neon.inc.c | ||
48 | +++ b/target/arm/translate-neon.inc.c | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | ||
50 | DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | ||
51 | DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | ||
52 | DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | ||
53 | + | ||
54 | +static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
55 | + NeonGenWidenFn *widenfn, bool u) | ||
56 | +{ | ||
57 | + TCGv_i64 tmp; | ||
58 | + TCGv_i32 rm0, rm1; | ||
59 | + uint64_t widen_mask = 0; | ||
60 | + | ||
61 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
66 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
67 | + ((a->vd | a->vm) & 0x10)) { | ||
68 | + return false; | ||
69 | + } | ||
70 | + | ||
71 | + if (a->vd & 1) { | ||
72 | + return false; | ||
73 | + } | ||
74 | + | ||
75 | + if (!vfp_access_check(s)) { | ||
76 | + return true; | ||
77 | + } | ||
78 | + | ||
79 | + /* | ||
80 | + * This is a widen-and-shift operation. The shift is always less | ||
81 | + * than the width of the source type, so after widening the input | ||
82 | + * vector we can simply shift the whole 64-bit widened register, | ||
83 | + * and then clear the potential overflow bits resulting from left | ||
84 | + * bits of the narrow input appearing as right bits of the left | ||
85 | + * neighbour narrow input. Calculate a mask of bits to clear. | ||
86 | + */ | ||
87 | + if ((a->shift != 0) && (a->size < 2 || u)) { | ||
88 | + int esize = 8 << a->size; | ||
89 | + widen_mask = MAKE_64BIT_MASK(0, esize); | ||
90 | + widen_mask >>= esize - a->shift; | ||
91 | + widen_mask = dup_const(a->size + 1, widen_mask); | ||
92 | + } | ||
93 | + | ||
94 | + rm0 = neon_load_reg(a->vm, 0); | ||
95 | + rm1 = neon_load_reg(a->vm, 1); | ||
96 | + tmp = tcg_temp_new_i64(); | ||
97 | + | ||
98 | + widenfn(tmp, rm0); | ||
99 | + if (a->shift != 0) { | ||
100 | + tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
101 | + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
102 | + } | ||
103 | + neon_store_reg64(tmp, a->vd); | ||
104 | + | ||
105 | + widenfn(tmp, rm1); | ||
106 | + if (a->shift != 0) { | ||
107 | + tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
108 | + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
109 | + } | ||
110 | + neon_store_reg64(tmp, a->vd + 1); | ||
111 | + tcg_temp_free_i64(tmp); | ||
112 | + return true; | ||
113 | +} | 60 | +} |
114 | + | 61 | + |
115 | +static bool trans_VSHLL_S_2sh(DisasContext *s, arg_2reg_shift *a) | 62 | static void cortex_r5f_initfn(Object *obj) |
116 | +{ | 63 | { |
117 | + NeonGenWidenFn *widenfn[] = { | 64 | ARMCPU *cpu = ARM_CPU(obj); |
118 | + gen_helper_neon_widen_s8, | 65 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { |
119 | + gen_helper_neon_widen_s16, | 66 | .class_init = arm_v7m_class_init }, |
120 | + tcg_gen_ext_i32_i64, | 67 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, |
121 | + }; | 68 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, |
122 | + return do_vshll_2sh(s, a, widenfn[a->size], false); | 69 | + { .name = "cortex-r52", .initfn = cortex_r52_initfn }, |
123 | +} | 70 | { .name = "ti925t", .initfn = ti925t_initfn }, |
124 | + | 71 | { .name = "sa1100", .initfn = sa1100_initfn }, |
125 | +static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | 72 | { .name = "sa1110", .initfn = sa1110_initfn }, |
126 | +{ | ||
127 | + NeonGenWidenFn *widenfn[] = { | ||
128 | + gen_helper_neon_widen_u8, | ||
129 | + gen_helper_neon_widen_u16, | ||
130 | + tcg_gen_extu_i32_i64, | ||
131 | + }; | ||
132 | + return do_vshll_2sh(s, a, widenfn[a->size], true); | ||
133 | +} | ||
134 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
135 | index XXXXXXX..XXXXXXX 100644 | ||
136 | --- a/target/arm/translate.c | ||
137 | +++ b/target/arm/translate.c | ||
138 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
139 | case 7: /* VQSHL */ | ||
140 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
141 | case 9: /* VQSHRN, VQRSHRN */ | ||
142 | + case 10: /* VSHLL, including VMOVL */ | ||
143 | return 1; /* handled by decodetree */ | ||
144 | default: | ||
145 | break; | ||
146 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
147 | size--; | ||
148 | } | ||
149 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
150 | - if (op == 10) { | ||
151 | - /* VSHLL, VMOVL */ | ||
152 | - if (q || (rd & 1)) { | ||
153 | - return 1; | ||
154 | - } | ||
155 | - tmp = neon_load_reg(rm, 0); | ||
156 | - tmp2 = neon_load_reg(rm, 1); | ||
157 | - for (pass = 0; pass < 2; pass++) { | ||
158 | - if (pass == 1) | ||
159 | - tmp = tmp2; | ||
160 | - | ||
161 | - gen_neon_widen(cpu_V0, tmp, size, u); | ||
162 | - | ||
163 | - if (shift != 0) { | ||
164 | - /* The shift is less than the width of the source | ||
165 | - type, so we can just shift the whole register. */ | ||
166 | - tcg_gen_shli_i64(cpu_V0, cpu_V0, shift); | ||
167 | - /* Widen the result of shift: we need to clear | ||
168 | - * the potential overflow bits resulting from | ||
169 | - * left bits of the narrow input appearing as | ||
170 | - * right bits of left the neighbour narrow | ||
171 | - * input. */ | ||
172 | - if (size < 2 || !u) { | ||
173 | - uint64_t imm64; | ||
174 | - if (size == 0) { | ||
175 | - imm = (0xffu >> (8 - shift)); | ||
176 | - imm |= imm << 16; | ||
177 | - } else if (size == 1) { | ||
178 | - imm = 0xffff >> (16 - shift); | ||
179 | - } else { | ||
180 | - /* size == 2 */ | ||
181 | - imm = 0xffffffff >> (32 - shift); | ||
182 | - } | ||
183 | - if (size < 2) { | ||
184 | - imm64 = imm | (((uint64_t)imm) << 32); | ||
185 | - } else { | ||
186 | - imm64 = imm; | ||
187 | - } | ||
188 | - tcg_gen_andi_i64(cpu_V0, cpu_V0, ~imm64); | ||
189 | - } | ||
190 | - } | ||
191 | - neon_store_reg64(cpu_V0, rd + pass); | ||
192 | - } | ||
193 | - } else if (op >= 14) { | ||
194 | + if (op >= 14) { | ||
195 | /* VCVT fixed-point. */ | ||
196 | TCGv_ptr fpst; | ||
197 | TCGv_i32 shiftv; | ||
198 | -- | 73 | -- |
199 | 2.20.1 | 74 | 2.25.1 |
200 | 75 | ||
201 | 76 | diff view generated by jsdifflib |
1 | Convert the VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree. | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | (These are the last instructions in the group that are vectorized; | ||
3 | the rest all require looping over each element.) | ||
4 | 2 | ||
3 | The check semihosting_enabled() wants to know if the guest is | ||
4 | currently in user mode. Unlike the other cases the test was inverted | ||
5 | causing us to block semihosting calls in non-EL0 modes. | ||
6 | |||
7 | Cc: qemu-stable@nongnu.org | ||
8 | Fixes: 19b26317e9 (target/arm: Honour -semihosting-config userspace=on) | ||
9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200522145520.6778-4-peter.maydell@linaro.org | ||
8 | --- | 12 | --- |
9 | target/arm/neon-dp.decode | 35 ++++++++++++++++++++++ | 13 | target/arm/translate.c | 2 +- |
10 | target/arm/translate-neon.inc.c | 7 +++++ | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | target/arm/translate.c | 52 +++------------------------------ | ||
12 | 3 files changed, 46 insertions(+), 48 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/neon-dp.decode | ||
17 | +++ b/target/arm/neon-dp.decode | ||
18 | @@ -XXX,XX +XXX,XX @@ VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
19 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
20 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
21 | |||
22 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | ||
23 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | ||
24 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | ||
25 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | ||
26 | + | ||
27 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | ||
28 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | ||
29 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | ||
30 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | ||
31 | + | ||
32 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_d | ||
33 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_s | ||
34 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_h | ||
35 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_b | ||
36 | + | ||
37 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_d | ||
38 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_s | ||
39 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_h | ||
40 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_b | ||
41 | + | ||
42 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_d | ||
43 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_s | ||
44 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_h | ||
45 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_b | ||
46 | + | ||
47 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_d | ||
48 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_s | ||
49 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_h | ||
50 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_b | ||
51 | + | ||
52 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_d | ||
53 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_s | ||
54 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_h | ||
55 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_b | ||
56 | + | ||
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
58 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
59 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
60 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate-neon.inc.c | ||
63 | +++ b/target/arm/translate-neon.inc.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
65 | |||
66 | DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
67 | DO_2SH(VSLI, gen_gvec_sli) | ||
68 | +DO_2SH(VSRI, gen_gvec_sri) | ||
69 | +DO_2SH(VSRA_S, gen_gvec_ssra) | ||
70 | +DO_2SH(VSRA_U, gen_gvec_usra) | ||
71 | +DO_2SH(VRSHR_S, gen_gvec_srshr) | ||
72 | +DO_2SH(VRSHR_U, gen_gvec_urshr) | ||
73 | +DO_2SH(VRSRA_S, gen_gvec_srsra) | ||
74 | +DO_2SH(VRSRA_U, gen_gvec_ursra) | ||
75 | |||
76 | static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
77 | { | ||
78 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
79 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
80 | --- a/target/arm/translate.c | 18 | --- a/target/arm/translate.c |
81 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/translate.c |
82 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 20 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) |
83 | 21 | * semihosting, to provide some semblance of security | |
84 | switch (op) { | 22 | * (and for consistency with our 32-bit semihosting). |
85 | case 0: /* VSHR */ | 23 | */ |
86 | + case 1: /* VSRA */ | 24 | - if (semihosting_enabled(s->current_el != 0) && |
87 | + case 2: /* VRSHR */ | 25 | + if (semihosting_enabled(s->current_el == 0) && |
88 | + case 3: /* VRSRA */ | 26 | (imm == (s->thumb ? 0x3c : 0xf000))) { |
89 | + case 4: /* VSRI */ | 27 | gen_exception_internal_insn(s, EXCP_SEMIHOST); |
90 | case 5: /* VSHL, VSLI */ | 28 | return; |
91 | return 1; /* handled by decodetree */ | ||
92 | default: | ||
93 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
94 | shift = shift - (1 << (size + 3)); | ||
95 | } | ||
96 | |||
97 | - switch (op) { | ||
98 | - case 1: /* VSRA */ | ||
99 | - /* Right shift comes here negative. */ | ||
100 | - shift = -shift; | ||
101 | - if (u) { | ||
102 | - gen_gvec_usra(size, rd_ofs, rm_ofs, shift, | ||
103 | - vec_size, vec_size); | ||
104 | - } else { | ||
105 | - gen_gvec_ssra(size, rd_ofs, rm_ofs, shift, | ||
106 | - vec_size, vec_size); | ||
107 | - } | ||
108 | - return 0; | ||
109 | - | ||
110 | - case 2: /* VRSHR */ | ||
111 | - /* Right shift comes here negative. */ | ||
112 | - shift = -shift; | ||
113 | - if (u) { | ||
114 | - gen_gvec_urshr(size, rd_ofs, rm_ofs, shift, | ||
115 | - vec_size, vec_size); | ||
116 | - } else { | ||
117 | - gen_gvec_srshr(size, rd_ofs, rm_ofs, shift, | ||
118 | - vec_size, vec_size); | ||
119 | - } | ||
120 | - return 0; | ||
121 | - | ||
122 | - case 3: /* VRSRA */ | ||
123 | - /* Right shift comes here negative. */ | ||
124 | - shift = -shift; | ||
125 | - if (u) { | ||
126 | - gen_gvec_ursra(size, rd_ofs, rm_ofs, shift, | ||
127 | - vec_size, vec_size); | ||
128 | - } else { | ||
129 | - gen_gvec_srsra(size, rd_ofs, rm_ofs, shift, | ||
130 | - vec_size, vec_size); | ||
131 | - } | ||
132 | - return 0; | ||
133 | - | ||
134 | - case 4: /* VSRI */ | ||
135 | - if (!u) { | ||
136 | - return 1; | ||
137 | - } | ||
138 | - /* Right shift comes here negative. */ | ||
139 | - shift = -shift; | ||
140 | - gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | ||
141 | - vec_size, vec_size); | ||
142 | - return 0; | ||
143 | - } | ||
144 | - | ||
145 | if (size == 3) { | ||
146 | count = q + 1; | ||
147 | } else { | ||
148 | -- | 29 | -- |
149 | 2.20.1 | 30 | 2.25.1 |
150 | 31 | ||
151 | 32 | 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 this conversion, we will be able to use the same helpers | 3 | Fix typos, add background information |
4 | with sve. This also fixes a bug in which we failed to clear | ||
5 | the high bits of the SVE register after an AdvSIMD operation. | ||
6 | 4 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
8 | Message-id: 20200514212831.31248-3-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 8 | --- |
12 | target/arm/helper.h | 2 ++ | 9 | hw/timer/imx_epit.c | 20 ++++++++++++++++---- |
13 | target/arm/translate-a64.h | 3 ++ | 10 | 1 file changed, 16 insertions(+), 4 deletions(-) |
14 | target/arm/crypto_helper.c | 11 +++++++ | ||
15 | target/arm/translate-a64.c | 59 ++++++++++++++++++++------------------ | ||
16 | 4 files changed, 47 insertions(+), 28 deletions(-) | ||
17 | 11 | ||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 12 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.h | 14 | --- a/hw/timer/imx_epit.c |
21 | +++ b/target/arm/helper.h | 15 | +++ b/hw/timer/imx_epit.c |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 16 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s) |
23 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
24 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
25 | |||
26 | +DEF_HELPER_FLAGS_4(crypto_rax1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
27 | + | ||
28 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | ||
29 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | ||
30 | |||
31 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/translate-a64.h | ||
34 | +++ b/target/arm/translate-a64.h | ||
35 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) | ||
36 | |||
37 | bool disas_sve(DisasContext *, uint32_t); | ||
38 | |||
39 | +void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
40 | + uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz); | ||
41 | + | ||
42 | #endif /* TARGET_ARM_TRANSLATE_A64_H */ | ||
43 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/crypto_helper.c | ||
46 | +++ b/target/arm/crypto_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm, uint32_t desc) | ||
48 | } | ||
49 | clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
50 | } | ||
51 | + | ||
52 | +void HELPER(crypto_rax1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
53 | +{ | ||
54 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
55 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
56 | + | ||
57 | + for (i = 0; i < opr_sz / 8; ++i) { | ||
58 | + d[i] = n[i] ^ rol64(m[i], 1); | ||
59 | + } | ||
60 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
61 | +} | ||
62 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/translate-a64.c | ||
65 | +++ b/target/arm/translate-a64.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
67 | tcg_temp_free_ptr(tcg_rn_ptr); | ||
68 | } | ||
69 | |||
70 | +static void gen_rax1_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) | ||
71 | +{ | ||
72 | + tcg_gen_rotli_i64(d, m, 1); | ||
73 | + tcg_gen_xor_i64(d, d, n); | ||
74 | +} | ||
75 | + | ||
76 | +static void gen_rax1_vec(unsigned vece, TCGv_vec d, TCGv_vec n, TCGv_vec m) | ||
77 | +{ | ||
78 | + tcg_gen_rotli_vec(vece, d, m, 1); | ||
79 | + tcg_gen_xor_vec(vece, d, d, n); | ||
80 | +} | ||
81 | + | ||
82 | +void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
83 | + uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz) | ||
84 | +{ | ||
85 | + static const TCGOpcode vecop_list[] = { INDEX_op_rotli_vec, 0 }; | ||
86 | + static const GVecGen3 op = { | ||
87 | + .fni8 = gen_rax1_i64, | ||
88 | + .fniv = gen_rax1_vec, | ||
89 | + .opt_opc = vecop_list, | ||
90 | + .fno = gen_helper_crypto_rax1, | ||
91 | + .vece = MO_64, | ||
92 | + }; | ||
93 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, &op); | ||
94 | +} | ||
95 | + | ||
96 | /* Crypto three-reg SHA512 | ||
97 | * 31 21 20 16 15 14 13 12 11 10 9 5 4 0 | ||
98 | * +-----------------------+------+---+---+-----+--------+------+------+ | ||
99 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
100 | bool feature; | ||
101 | CryptoThreeOpFn *genfn = NULL; | ||
102 | gen_helper_gvec_3 *oolfn = NULL; | ||
103 | + GVecGen3Fn *gvecfn = NULL; | ||
104 | |||
105 | if (o == 0) { | ||
106 | switch (opcode) { | ||
107 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
108 | break; | ||
109 | case 3: /* RAX1 */ | ||
110 | feature = dc_isar_feature(aa64_sha3, s); | ||
111 | - genfn = NULL; | ||
112 | + gvecfn = gen_gvec_rax1; | ||
113 | break; | ||
114 | default: | ||
115 | g_assert_not_reached(); | ||
116 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
117 | |||
118 | if (oolfn) { | ||
119 | gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
120 | - return; | ||
121 | - } | ||
122 | - | ||
123 | - if (genfn) { | ||
124 | + } else if (gvecfn) { | ||
125 | + gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
126 | + } else { | ||
127 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
128 | |||
129 | tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
130 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
131 | tcg_temp_free_ptr(tcg_rd_ptr); | ||
132 | tcg_temp_free_ptr(tcg_rn_ptr); | ||
133 | tcg_temp_free_ptr(tcg_rm_ptr); | ||
134 | - } else { | ||
135 | - TCGv_i64 tcg_op1, tcg_op2, tcg_res[2]; | ||
136 | - int pass; | ||
137 | - | ||
138 | - tcg_op1 = tcg_temp_new_i64(); | ||
139 | - tcg_op2 = tcg_temp_new_i64(); | ||
140 | - tcg_res[0] = tcg_temp_new_i64(); | ||
141 | - tcg_res[1] = tcg_temp_new_i64(); | ||
142 | - | ||
143 | - for (pass = 0; pass < 2; pass++) { | ||
144 | - read_vec_element(s, tcg_op1, rn, pass, MO_64); | ||
145 | - read_vec_element(s, tcg_op2, rm, pass, MO_64); | ||
146 | - | ||
147 | - tcg_gen_rotli_i64(tcg_res[pass], tcg_op2, 1); | ||
148 | - tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); | ||
149 | - } | ||
150 | - write_vec_element(s, tcg_res[0], rd, 0, MO_64); | ||
151 | - write_vec_element(s, tcg_res[1], rd, 1, MO_64); | ||
152 | - | ||
153 | - tcg_temp_free_i64(tcg_op1); | ||
154 | - tcg_temp_free_i64(tcg_op2); | ||
155 | - tcg_temp_free_i64(tcg_res[0]); | ||
156 | - tcg_temp_free_i64(tcg_res[1]); | ||
157 | } | 17 | } |
158 | } | 18 | } |
159 | 19 | ||
20 | +/* | ||
21 | + * This is called both on hardware (device) reset and software reset. | ||
22 | + */ | ||
23 | static void imx_epit_reset(DeviceState *dev) | ||
24 | { | ||
25 | IMXEPITState *s = IMX_EPIT(dev); | ||
26 | |||
27 | - /* | ||
28 | - * Soft reset doesn't touch some bits; hard reset clears them | ||
29 | - */ | ||
30 | + /* Soft reset doesn't touch some bits; hard reset clears them */ | ||
31 | s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); | ||
32 | s->sr = 0; | ||
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 | } | ||
69 | |||
160 | -- | 70 | -- |
161 | 2.20.1 | 71 | 2.25.1 |
162 | |||
163 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Axel Heider <axel.heider@hensoldt.net> | ||
1 | 2 | ||
3 | remove unused defines, add needed defines | ||
4 | |||
5 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | include/hw/timer/imx_epit.h | 4 ++-- | ||
10 | hw/timer/imx_epit.c | 4 ++-- | ||
11 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
12 | |||
13 | diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/timer/imx_epit.h | ||
16 | +++ b/include/hw/timer/imx_epit.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #define CR_OCIEN (1 << 2) | ||
19 | #define CR_RLD (1 << 3) | ||
20 | #define CR_PRESCALE_SHIFT (4) | ||
21 | -#define CR_PRESCALE_MASK (0xfff) | ||
22 | +#define CR_PRESCALE_BITS (12) | ||
23 | #define CR_SWR (1 << 16) | ||
24 | #define CR_IOVW (1 << 17) | ||
25 | #define CR_DBGEN (1 << 18) | ||
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 | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/timer/imx_epit.c | ||
38 | +++ b/hw/timer/imx_epit.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s) | ||
40 | uint32_t clksrc; | ||
41 | uint32_t prescaler; | ||
42 | |||
43 | - clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, 2); | ||
44 | - prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, 12); | ||
45 | + clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS); | ||
46 | + prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS); | ||
47 | |||
48 | s->freq = imx_ccm_get_clock_frequency(s->ccm, | ||
49 | imx_epit_clocks[clksrc]) / prescaler; | ||
50 | -- | ||
51 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | The ADC region size is 256B, split as: | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | - [0x00 - 0x4f] defined | ||
5 | - [0x50 - 0xff] reserved | ||
6 | |||
7 | All registers are 32-bit (thus when the datasheet mentions the | ||
8 | last defined register is 0x4c, it means its address range is | ||
9 | 0x4c .. 0x4f. | ||
10 | |||
11 | This model implementation is also 32-bit. Set MemoryRegionOps | ||
12 | 'impl' fields. | ||
13 | |||
14 | See: | ||
15 | 'RM0033 Reference manual Rev 8', Table 10.13.18 "ADC register map". | ||
16 | |||
17 | Reported-by: Seth Kintigh <skintigh@gmail.com> | ||
18 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
19 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20200603055915.17678-1-f4bug@amsat.org | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 5 | --- |
23 | hw/adc/stm32f2xx_adc.c | 4 +++- | 6 | include/hw/timer/imx_epit.h | 2 ++ |
24 | 1 file changed, 3 insertions(+), 1 deletion(-) | 7 | hw/timer/imx_epit.c | 12 ++++++------ |
8 | 2 files changed, 8 insertions(+), 6 deletions(-) | ||
25 | 9 | ||
26 | diff --git a/hw/adc/stm32f2xx_adc.c b/hw/adc/stm32f2xx_adc.c | 10 | diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h |
27 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/adc/stm32f2xx_adc.c | 12 | --- a/include/hw/timer/imx_epit.h |
29 | +++ b/hw/adc/stm32f2xx_adc.c | 13 | +++ b/include/hw/timer/imx_epit.h |
30 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps stm32f2xx_adc_ops = { | 14 | @@ -XXX,XX +XXX,XX @@ |
31 | .read = stm32f2xx_adc_read, | 15 | #define CR_CLKSRC_SHIFT (24) |
32 | .write = stm32f2xx_adc_write, | 16 | #define CR_CLKSRC_BITS (2) |
33 | .endianness = DEVICE_NATIVE_ENDIAN, | 17 | |
34 | + .impl.min_access_size = 4, | 18 | +#define SR_OCIF (1 << 0) |
35 | + .impl.max_access_size = 4, | 19 | + |
36 | }; | 20 | #define EPIT_TIMER_MAX 0XFFFFFFFFUL |
37 | 21 | ||
38 | static const VMStateDescription vmstate_stm32f2xx_adc = { | 22 | #define TYPE_IMX_EPIT "imx.epit" |
39 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_adc_init(Object *obj) | 23 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
40 | sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | 24 | index XXXXXXX..XXXXXXX 100644 |
41 | 25 | --- a/hw/timer/imx_epit.c | |
42 | memory_region_init_io(&s->mmio, obj, &stm32f2xx_adc_ops, s, | 26 | +++ b/hw/timer/imx_epit.c |
43 | - TYPE_STM32F2XX_ADC, 0xFF); | 27 | @@ -XXX,XX +XXX,XX @@ static const IMXClk imx_epit_clocks[] = { |
44 | + TYPE_STM32F2XX_ADC, 0x100); | 28 | */ |
45 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | 29 | static void imx_epit_update_int(IMXEPITState *s) |
30 | { | ||
31 | - if (s->sr && (s->cr & CR_OCIEN) && (s->cr & CR_EN)) { | ||
32 | + if ((s->sr & SR_OCIF) && (s->cr & CR_OCIEN) && (s->cr & CR_EN)) { | ||
33 | qemu_irq_raise(s->irq); | ||
34 | } else { | ||
35 | qemu_irq_lower(s->irq); | ||
36 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | ||
37 | break; | ||
38 | |||
39 | case 1: /* SR - ACK*/ | ||
40 | - /* writing 1 to OCIF clears the OCIF bit */ | ||
41 | - if (value & 0x01) { | ||
42 | - s->sr = 0; | ||
43 | + /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */ | ||
44 | + if (value & SR_OCIF) { | ||
45 | + s->sr = 0; /* SR.OCIF is the only bit in this register anyway */ | ||
46 | imx_epit_update_int(s); | ||
47 | } | ||
48 | break; | ||
49 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_cmp(void *opaque) | ||
50 | IMXEPITState *s = IMX_EPIT(opaque); | ||
51 | |||
52 | DPRINTF("sr was %d\n", s->sr); | ||
53 | - | ||
54 | - s->sr = 1; | ||
55 | + /* Set interrupt status bit SR.OCIF and update the interrupt state */ | ||
56 | + s->sr |= SR_OCIF; | ||
57 | imx_epit_update_int(s); | ||
46 | } | 58 | } |
47 | 59 | ||
48 | -- | 60 | -- |
49 | 2.20.1 | 61 | 2.25.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | When inserting the value retrieved (rx) from the spi slave, rx is pushed to | 3 | The interrupt state can change due to: |
4 | rx_fifo after being cast to uint8_t. rx_fifo is a fifo32, and the rx | 4 | - reset clears both SR.OCIF and CR.OCIE |
5 | register the driver uses is also 32 bit. This zeroes the 24 most | 5 | - write to CR.EN or CR.OCIE |
6 | significant bits of rx. This proved problematic with devices that expect to | ||
7 | use the whole 32 bits of the rx register. | ||
8 | 6 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | 7 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 11 | hw/timer/imx_epit.c | 16 ++++++++++++---- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 12 insertions(+), 4 deletions(-) |
15 | 13 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 14 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 16 | --- a/hw/timer/imx_epit.c |
19 | +++ b/hw/ssi/imx_spi.c | 17 | +++ b/hw/timer/imx_epit.c |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 18 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, |
21 | if (fifo32_is_full(&s->rx_fifo)) { | 19 | if (s->cr & CR_SWR) { |
22 | s->regs[ECSPI_STATREG] |= ECSPI_STATREG_RO; | 20 | /* handle the reset */ |
23 | } else { | 21 | imx_epit_reset(DEVICE(s)); |
24 | - fifo32_push(&s->rx_fifo, (uint8_t)rx); | 22 | - /* |
25 | + fifo32_push(&s->rx_fifo, rx); | 23 | - * TODO: could we 'break' here? following operations appear |
24 | - * to duplicate the work imx_epit_reset() already did. | ||
25 | - */ | ||
26 | } | 26 | } |
27 | 27 | ||
28 | if (s->burst_length <= 0) { | 28 | + /* |
29 | + * The interrupt state can change due to: | ||
30 | + * - reset clears both SR.OCIF and CR.OCIE | ||
31 | + * - write to CR.EN or CR.OCIE | ||
32 | + */ | ||
33 | + imx_epit_update_int(s); | ||
34 | + | ||
35 | + /* | ||
36 | + * TODO: could we 'break' here for reset? following operations appear | ||
37 | + * to duplicate the work imx_epit_reset() already did. | ||
38 | + */ | ||
39 | + | ||
40 | ptimer_transaction_begin(s->timer_cmp); | ||
41 | ptimer_transaction_begin(s->timer_reload); | ||
42 | |||
29 | -- | 43 | -- |
30 | 2.20.1 | 44 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | Convert the VSHR 2-reg-shift insns to decodetree. | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Note that unlike the legacy decoder, we present the right shift | 3 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
4 | amount to the trans_ function as a positive integer. | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | --- | ||
7 | hw/timer/imx_epit.c | 20 ++++++++++++++------ | ||
8 | 1 file changed, 14 insertions(+), 6 deletions(-) | ||
5 | 9 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200522145520.6778-3-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++ | ||
11 | target/arm/translate-neon.inc.c | 41 +++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate.c | 21 +---------------- | ||
13 | 3 files changed, 67 insertions(+), 20 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
16 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/neon-dp.decode | 12 | --- a/hw/timer/imx_epit.c |
18 | +++ b/target/arm/neon-dp.decode | 13 | +++ b/hw/timer/imx_epit.c |
19 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 14 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s) |
20 | ###################################################################### | 15 | /* |
21 | &2reg_shift vm vd q shift size | 16 | * This is called both on hardware (device) reset and software reset. |
22 | 17 | */ | |
23 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | 18 | -static void imx_epit_reset(DeviceState *dev) |
24 | +%neon_rshift_i6 16:6 !function=rsub_64 | 19 | +static void imx_epit_reset(IMXEPITState *s, bool is_hard_reset) |
25 | +%neon_rshift_i5 16:5 !function=rsub_32 | 20 | { |
26 | +%neon_rshift_i4 16:4 !function=rsub_16 | 21 | - IMXEPITState *s = IMX_EPIT(dev); |
27 | +%neon_rshift_i3 16:3 !function=rsub_8 | 22 | - |
28 | + | 23 | /* Soft reset doesn't touch some bits; hard reset clears them */ |
29 | +@2reg_shr_d .... ... . . . ...... .... .... 1 q:1 . . .... \ | 24 | - s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); |
30 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 shift=%neon_rshift_i6 | 25 | + if (is_hard_reset) { |
31 | +@2reg_shr_s .... ... . . . 1 ..... .... .... 0 q:1 . . .... \ | 26 | + s->cr = 0; |
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 shift=%neon_rshift_i5 | 27 | + } else { |
33 | +@2reg_shr_h .... ... . . . 01 .... .... .... 0 q:1 . . .... \ | 28 | + s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN); |
34 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 shift=%neon_rshift_i4 | 29 | + } |
35 | +@2reg_shr_b .... ... . . . 001 ... .... .... 0 q:1 . . .... \ | 30 | s->sr = 0; |
36 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i3 | 31 | s->lr = EPIT_TIMER_MAX; |
37 | + | 32 | s->cmp = 0; |
38 | @2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | 33 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, |
39 | &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | 34 | s->cr = value & 0x03ffffff; |
40 | @2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | 35 | if (s->cr & CR_SWR) { |
41 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 36 | /* handle the reset */ |
42 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 37 | - imx_epit_reset(DEVICE(s)); |
43 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 38 | + imx_epit_reset(s, false); |
44 | 39 | } | |
45 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 40 | |
46 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 41 | /* |
47 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 42 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_realize(DeviceState *dev, Error **errp) |
48 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | 43 | s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_LEGACY); |
49 | + | ||
50 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
51 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
52 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
53 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
54 | + | ||
55 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
56 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/translate-neon.inc.c | ||
61 | +++ b/target/arm/translate-neon.inc.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
63 | return x + 1; | ||
64 | } | 44 | } |
65 | 45 | ||
66 | +static inline int rsub_64(DisasContext *s, int x) | 46 | +static void imx_epit_dev_reset(DeviceState *dev) |
67 | +{ | 47 | +{ |
68 | + return 64 - x; | 48 | + IMXEPITState *s = IMX_EPIT(dev); |
49 | + imx_epit_reset(s, true); | ||
69 | +} | 50 | +} |
70 | + | 51 | + |
71 | +static inline int rsub_32(DisasContext *s, int x) | 52 | static void imx_epit_class_init(ObjectClass *klass, void *data) |
72 | +{ | 53 | { |
73 | + return 32 - x; | 54 | DeviceClass *dc = DEVICE_CLASS(klass); |
74 | +} | 55 | |
75 | +static inline int rsub_16(DisasContext *s, int x) | 56 | dc->realize = imx_epit_realize; |
76 | +{ | 57 | - dc->reset = imx_epit_reset; |
77 | + return 16 - x; | 58 | + dc->reset = imx_epit_dev_reset; |
78 | +} | 59 | dc->vmsd = &vmstate_imx_timer_epit; |
79 | +static inline int rsub_8(DisasContext *s, int x) | 60 | dc->desc = "i.MX periodic timer"; |
80 | +{ | 61 | } |
81 | + return 8 - x; | ||
82 | +} | ||
83 | + | ||
84 | /* Include the generated Neon decoder */ | ||
85 | #include "decode-neon-dp.inc.c" | ||
86 | #include "decode-neon-ls.inc.c" | ||
87 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
88 | |||
89 | DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
90 | DO_2SH(VSLI, gen_gvec_sli) | ||
91 | + | ||
92 | +static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
93 | +{ | ||
94 | + /* Signed shift out of range results in all-sign-bits */ | ||
95 | + a->shift = MIN(a->shift, (8 << a->size) - 1); | ||
96 | + return do_vector_2sh(s, a, tcg_gen_gvec_sari); | ||
97 | +} | ||
98 | + | ||
99 | +static void gen_zero_rd_2sh(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs, | ||
100 | + int64_t shift, uint32_t oprsz, uint32_t maxsz) | ||
101 | +{ | ||
102 | + tcg_gen_gvec_dup_imm(vece, rd_ofs, oprsz, maxsz, 0); | ||
103 | +} | ||
104 | + | ||
105 | +static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
106 | +{ | ||
107 | + /* Shift out of range is architecturally valid and results in zero. */ | ||
108 | + if (a->shift >= (8 << a->size)) { | ||
109 | + return do_vector_2sh(s, a, gen_zero_rd_2sh); | ||
110 | + } else { | ||
111 | + return do_vector_2sh(s, a, tcg_gen_gvec_shri); | ||
112 | + } | ||
113 | +} | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/target/arm/translate.c | ||
117 | +++ b/target/arm/translate.c | ||
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
119 | op = (insn >> 8) & 0xf; | ||
120 | |||
121 | switch (op) { | ||
122 | + case 0: /* VSHR */ | ||
123 | case 5: /* VSHL, VSLI */ | ||
124 | return 1; /* handled by decodetree */ | ||
125 | default: | ||
126 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | |||
129 | switch (op) { | ||
130 | - case 0: /* VSHR */ | ||
131 | - /* Right shift comes here negative. */ | ||
132 | - shift = -shift; | ||
133 | - /* Shifts larger than the element size are architecturally | ||
134 | - * valid. Unsigned results in all zeros; signed results | ||
135 | - * in all sign bits. | ||
136 | - */ | ||
137 | - if (!u) { | ||
138 | - tcg_gen_gvec_sari(size, rd_ofs, rm_ofs, | ||
139 | - MIN(shift, (8 << size) - 1), | ||
140 | - vec_size, vec_size); | ||
141 | - } else if (shift >= 8 << size) { | ||
142 | - tcg_gen_gvec_dup_imm(MO_8, rd_ofs, vec_size, | ||
143 | - vec_size, 0); | ||
144 | - } else { | ||
145 | - tcg_gen_gvec_shri(size, rd_ofs, rm_ofs, shift, | ||
146 | - vec_size, vec_size); | ||
147 | - } | ||
148 | - return 0; | ||
149 | - | ||
150 | case 1: /* VSRA */ | ||
151 | /* Right shift comes here negative. */ | ||
152 | shift = -shift; | ||
153 | -- | 62 | -- |
154 | 2.20.1 | 63 | 2.25.1 |
155 | |||
156 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | 2 | ||
3 | Replace printf() calls by qemu_log_mask(), which is disabled | 3 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> |
4 | by default. This avoid flooding the terminal when fuzzing the | ||
5 | device. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20200525114123.21317-3-f4bug@amsat.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 6 | --- |
12 | hw/arm/pxa2xx.c | 66 ++++++++++++++++++++++++++++++++++++------------- | 7 | hw/timer/imx_epit.c | 215 ++++++++++++++++++++++++-------------------- |
13 | 1 file changed, 49 insertions(+), 17 deletions(-) | 8 | 1 file changed, 117 insertions(+), 98 deletions(-) |
14 | 9 | ||
15 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.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/hw/arm/pxa2xx.c | 12 | --- a/hw/timer/imx_epit.c |
18 | +++ b/hw/arm/pxa2xx.c | 13 | +++ b/hw/timer/imx_epit.c |
19 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s) |
20 | #include "sysemu/blockdev.h" | ||
21 | #include "sysemu/qtest.h" | ||
22 | #include "qemu/cutils.h" | ||
23 | +#include "qemu/log.h" | ||
24 | |||
25 | static struct { | ||
26 | hwaddr io_base; | ||
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr, | ||
28 | return s->pm_regs[addr >> 2]; | ||
29 | default: | ||
30 | fail: | ||
31 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
32 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
33 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
34 | + __func__, addr); | ||
35 | break; | ||
36 | } | ||
37 | return 0; | ||
38 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pm_write(void *opaque, hwaddr addr, | ||
39 | s->pm_regs[addr >> 2] = value; | ||
40 | break; | ||
41 | } | ||
42 | - | ||
43 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
44 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
45 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
46 | + __func__, addr); | ||
47 | break; | ||
48 | } | 15 | } |
49 | } | 16 | } |
50 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_cm_read(void *opaque, hwaddr addr, | 17 | |
51 | return s->cm_regs[CCCR >> 2] | (3 << 28); | 18 | +static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
19 | +{ | ||
20 | + uint32_t oldcr = s->cr; | ||
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) | ||
130 | { | ||
131 | IMXEPITState *s = IMX_EPIT(opaque); | ||
132 | - uint64_t oldcr; | ||
133 | |||
134 | DPRINTF("(%s, value = 0x%08x)\n", imx_epit_reg_name(offset >> 2), | ||
135 | (uint32_t)value); | ||
136 | |||
137 | switch (offset >> 2) { | ||
138 | case 0: /* CR */ | ||
139 | - | ||
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; | ||
52 | 249 | ||
53 | default: | 250 | default: |
54 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 251 | qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" |
55 | + qemu_log_mask(LOG_GUEST_ERROR, | 252 | HWADDR_PRIx "\n", TYPE_IMX_EPIT, __func__, offset); |
56 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 253 | - |
57 | + __func__, addr); | ||
58 | break; | ||
59 | } | ||
60 | return 0; | ||
61 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_cm_write(void *opaque, hwaddr addr, | ||
62 | break; | ||
63 | |||
64 | default: | ||
65 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
66 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
67 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
68 | + __func__, addr); | ||
69 | break; | 254 | break; |
70 | } | 255 | } |
71 | } | 256 | } |
72 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_mm_read(void *opaque, hwaddr addr, | 257 | + |
73 | return s->mm_regs[addr >> 2]; | 258 | static void imx_epit_cmp(void *opaque) |
74 | /* fall through */ | 259 | { |
75 | default: | 260 | IMXEPITState *s = IMX_EPIT(opaque); |
76 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
77 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
78 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
79 | + __func__, addr); | ||
80 | break; | ||
81 | } | ||
82 | return 0; | ||
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mm_write(void *opaque, hwaddr addr, | ||
84 | } | ||
85 | |||
86 | default: | ||
87 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
88 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
89 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
90 | + __func__, addr); | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_ssp_read(void *opaque, hwaddr addr, | ||
95 | case SSACD: | ||
96 | return s->ssacd; | ||
97 | default: | ||
98 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
99 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
100 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
101 | + __func__, addr); | ||
102 | break; | ||
103 | } | ||
104 | return 0; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_ssp_write(void *opaque, hwaddr addr, | ||
106 | break; | ||
107 | |||
108 | default: | ||
109 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
110 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
111 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
112 | + __func__, addr); | ||
113 | break; | ||
114 | } | ||
115 | } | ||
116 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr, | ||
117 | else | ||
118 | return s->last_swcr; | ||
119 | default: | ||
120 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
121 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
122 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
123 | + __func__, addr); | ||
124 | break; | ||
125 | } | ||
126 | return 0; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_rtc_write(void *opaque, hwaddr addr, | ||
128 | break; | ||
129 | |||
130 | default: | ||
131 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
132 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
133 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
134 | + __func__, addr); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr, | ||
139 | s->ibmr = 0; | ||
140 | return s->ibmr; | ||
141 | default: | ||
142 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
143 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
144 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
145 | + __func__, addr); | ||
146 | break; | ||
147 | } | ||
148 | return 0; | ||
149 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr, | ||
150 | break; | ||
151 | |||
152 | default: | ||
153 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
154 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
155 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
156 | + __func__, addr); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_i2s_read(void *opaque, hwaddr addr, | ||
161 | } | ||
162 | return 0; | ||
163 | default: | ||
164 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
165 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
166 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
167 | + __func__, addr); | ||
168 | break; | ||
169 | } | ||
170 | return 0; | ||
171 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_i2s_write(void *opaque, hwaddr addr, | ||
172 | } | ||
173 | break; | ||
174 | default: | ||
175 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
176 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
177 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
178 | + __func__, addr); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_fir_read(void *opaque, hwaddr addr, | ||
183 | case ICFOR: | ||
184 | return s->rx_len; | ||
185 | default: | ||
186 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
187 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
188 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
189 | + __func__, addr); | ||
190 | break; | ||
191 | } | ||
192 | return 0; | ||
193 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_fir_write(void *opaque, hwaddr addr, | ||
194 | case ICFOR: | ||
195 | break; | ||
196 | default: | ||
197 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
198 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
199 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
200 | + __func__, addr); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | -- | 261 | -- |
205 | 2.20.1 | 262 | 2.25.1 |
206 | |||
207 | diff view generated by jsdifflib |
1 | Convert the remaining Neon narrowing shifts to decodetree: | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | * VQSHRN | ||
3 | * VQRSHRN | ||
4 | 2 | ||
3 | The CNT register is a read-only register. There is no need to | ||
4 | store it's value, it can be calculated on demand. | ||
5 | The calculated frequency is needed temporarily only. | ||
6 | |||
7 | Note that this is a migration compatibility break for all boards | ||
8 | types that use the EPIT peripheral. | ||
9 | |||
10 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200522145520.6778-7-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | target/arm/neon-dp.decode | 20 ++++++ | 14 | include/hw/timer/imx_epit.h | 2 - |
10 | target/arm/translate-neon.inc.c | 15 +++++ | 15 | hw/timer/imx_epit.c | 73 ++++++++++++++----------------------- |
11 | target/arm/translate.c | 110 +------------------------------- | 16 | 2 files changed, 28 insertions(+), 47 deletions(-) |
12 | 3 files changed, 37 insertions(+), 108 deletions(-) | ||
13 | 17 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 18 | diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 20 | --- a/include/hw/timer/imx_epit.h |
17 | +++ b/target/arm/neon-dp.decode | 21 | +++ b/include/hw/timer/imx_epit.h |
18 | @@ -XXX,XX +XXX,XX @@ VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | 22 | @@ -XXX,XX +XXX,XX @@ struct IMXEPITState { |
19 | VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | 23 | uint32_t sr; |
20 | VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | 24 | uint32_t lr; |
21 | VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | 25 | uint32_t cmp; |
22 | + | 26 | - uint32_t cnt; |
23 | +# VQSHRN with signed input | 27 | |
24 | +VQSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | 28 | - uint32_t freq; |
25 | +VQSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | 29 | qemu_irq irq; |
26 | +VQSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | 30 | }; |
27 | + | 31 | |
28 | +# VQRSHRN with signed input | 32 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
29 | +VQRSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
30 | +VQRSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
31 | +VQRSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
32 | + | ||
33 | +# VQSHRN with unsigned input | ||
34 | +VQSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | ||
35 | +VQSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | ||
36 | +VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
37 | + | ||
38 | +# VQRSHRN with unsigned input | ||
39 | +VQRSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
40 | +VQRSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
41 | +VQRSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
42 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/target/arm/translate-neon.inc.c | 34 | --- a/hw/timer/imx_epit.c |
45 | +++ b/target/arm/translate-neon.inc.c | 35 | +++ b/hw/timer/imx_epit.c |
46 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | 36 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_update_int(IMXEPITState *s) |
47 | DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | ||
48 | DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | ||
49 | DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | ||
50 | +DO_2SN_64(VQSHRN_S64, gen_sshl_i64, gen_helper_neon_narrow_sat_s32) | ||
51 | +DO_2SN_32(VQSHRN_S32, gen_sshl_i32, gen_helper_neon_narrow_sat_s16) | ||
52 | +DO_2SN_32(VQSHRN_S16, gen_helper_neon_shl_s16, gen_helper_neon_narrow_sat_s8) | ||
53 | + | ||
54 | +DO_2SN_64(VQRSHRN_S64, gen_helper_neon_rshl_s64, gen_helper_neon_narrow_sat_s32) | ||
55 | +DO_2SN_32(VQRSHRN_S32, gen_helper_neon_rshl_s32, gen_helper_neon_narrow_sat_s16) | ||
56 | +DO_2SN_32(VQRSHRN_S16, gen_helper_neon_rshl_s16, gen_helper_neon_narrow_sat_s8) | ||
57 | + | ||
58 | +DO_2SN_64(VQSHRN_U64, gen_ushl_i64, gen_helper_neon_narrow_sat_u32) | ||
59 | +DO_2SN_32(VQSHRN_U32, gen_ushl_i32, gen_helper_neon_narrow_sat_u16) | ||
60 | +DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | ||
61 | + | ||
62 | +DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | ||
63 | +DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | ||
64 | +DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | ||
65 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/translate.c | ||
68 | +++ b/target/arm/translate.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_unarrow_sats(int size, TCGv_i32 dest, TCGv_i64 src) | ||
70 | } | 37 | } |
71 | } | 38 | } |
72 | 39 | ||
73 | -static inline void gen_neon_shift_narrow(int size, TCGv_i32 var, TCGv_i32 shift, | 40 | -/* |
74 | - int q, int u) | 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 */ | ||
79 | + | ||
80 | + /* | ||
81 | + * The reset switches off the input clock, so even if the CR.EN is still | ||
82 | + * set, the timers are no longer running. | ||
83 | + */ | ||
84 | + assert(imx_epit_get_freq(s) == 0); | ||
85 | ptimer_stop(s->timer_cmp); | ||
86 | ptimer_stop(s->timer_reload); | ||
87 | - /* compute new frequency */ | ||
88 | - imx_epit_set_freq(s); | ||
89 | /* init both timers to EPIT_TIMER_MAX */ | ||
90 | ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1); | ||
91 | ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1); | ||
92 | - if (s->freq && (s->cr & CR_EN)) { | ||
93 | - /* if the timer is still enabled, restart it */ | ||
94 | - ptimer_run(s->timer_reload, 0); | ||
95 | - } | ||
96 | ptimer_transaction_commit(s->timer_cmp); | ||
97 | ptimer_transaction_commit(s->timer_reload); | ||
98 | } | ||
99 | |||
100 | -static uint32_t imx_epit_update_count(IMXEPITState *s) | ||
75 | -{ | 101 | -{ |
76 | - if (q) { | 102 | - s->cnt = ptimer_get_count(s->timer_reload); |
77 | - if (u) { | 103 | - |
78 | - switch (size) { | 104 | - return s->cnt; |
79 | - case 1: gen_helper_neon_rshl_u16(var, var, shift); break; | ||
80 | - case 2: gen_helper_neon_rshl_u32(var, var, shift); break; | ||
81 | - default: abort(); | ||
82 | - } | ||
83 | - } else { | ||
84 | - switch (size) { | ||
85 | - case 1: gen_helper_neon_rshl_s16(var, var, shift); break; | ||
86 | - case 2: gen_helper_neon_rshl_s32(var, var, shift); break; | ||
87 | - default: abort(); | ||
88 | - } | ||
89 | - } | ||
90 | - } else { | ||
91 | - if (u) { | ||
92 | - switch (size) { | ||
93 | - case 1: gen_helper_neon_shl_u16(var, var, shift); break; | ||
94 | - case 2: gen_ushl_i32(var, var, shift); break; | ||
95 | - default: abort(); | ||
96 | - } | ||
97 | - } else { | ||
98 | - switch (size) { | ||
99 | - case 1: gen_helper_neon_shl_s16(var, var, shift); break; | ||
100 | - case 2: gen_sshl_i32(var, var, shift); break; | ||
101 | - default: abort(); | ||
102 | - } | ||
103 | - } | ||
104 | - } | ||
105 | -} | 105 | -} |
106 | - | 106 | - |
107 | static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | 107 | static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) |
108 | { | 108 | { |
109 | if (u) { | 109 | IMXEPITState *s = IMX_EPIT(opaque); |
110 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 110 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) |
111 | case 6: /* VQSHLU */ | 111 | break; |
112 | case 7: /* VQSHL */ | 112 | |
113 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | 113 | case 4: /* CNT */ |
114 | + case 9: /* VQSHRN, VQRSHRN */ | 114 | - imx_epit_update_count(s); |
115 | return 1; /* handled by decodetree */ | 115 | - reg_value = s->cnt; |
116 | default: | 116 | + reg_value = ptimer_get_count(s->timer_reload); |
117 | break; | 117 | break; |
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 118 | |
119 | size--; | 119 | default: |
120 | } | 120 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s) |
121 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 121 | { |
122 | - if (op < 10) { | 122 | if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN)) { |
123 | - /* Shift by immediate and narrow: | 123 | /* if the compare feature is on and timers are running */ |
124 | - VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | 124 | - uint32_t tmp = imx_epit_update_count(s); |
125 | - int input_unsigned = (op == 8) ? !u : u; | 125 | + uint32_t tmp = ptimer_get_count(s->timer_reload); |
126 | - if (rm & 1) { | 126 | uint64_t next; |
127 | - return 1; | 127 | if (tmp > s->cmp) { |
128 | - } | 128 | /* It'll fire in this round of the timer */ |
129 | - shift = shift - (1 << (size + 3)); | 129 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s) |
130 | - size++; | 130 | |
131 | - if (size == 3) { | 131 | static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
132 | - tmp64 = tcg_const_i64(shift); | 132 | { |
133 | - neon_load_reg64(cpu_V0, rm); | 133 | + uint32_t freq = 0; |
134 | - neon_load_reg64(cpu_V1, rm + 1); | 134 | uint32_t oldcr = s->cr; |
135 | - for (pass = 0; pass < 2; pass++) { | 135 | |
136 | - TCGv_i64 in; | 136 | s->cr = value & 0x03ffffff; |
137 | - if (pass == 0) { | 137 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
138 | - in = cpu_V0; | 138 | ptimer_transaction_begin(s->timer_cmp); |
139 | - } else { | 139 | ptimer_transaction_begin(s->timer_reload); |
140 | - in = cpu_V1; | 140 | |
141 | - } | 141 | - /* Update the frequency. Has been done already in case of a reset. */ |
142 | - if (q) { | 142 | + /* |
143 | - if (input_unsigned) { | 143 | + * Update the frequency. In case of a reset the input clock was |
144 | - gen_helper_neon_rshl_u64(cpu_V0, in, tmp64); | 144 | + * switched off, so this can be skipped. |
145 | - } else { | 145 | + */ |
146 | - gen_helper_neon_rshl_s64(cpu_V0, in, tmp64); | 146 | if (!(s->cr & CR_SWR)) { |
147 | - } | 147 | - imx_epit_set_freq(s); |
148 | - } else { | 148 | + freq = imx_epit_get_freq(s); |
149 | - if (input_unsigned) { | 149 | + if (freq) { |
150 | - gen_ushl_i64(cpu_V0, in, tmp64); | 150 | + ptimer_set_freq(s->timer_reload, freq); |
151 | - } else { | 151 | + ptimer_set_freq(s->timer_cmp, freq); |
152 | - gen_sshl_i64(cpu_V0, in, tmp64); | 152 | + } |
153 | - } | 153 | } |
154 | - } | 154 | |
155 | - tmp = tcg_temp_new_i32(); | 155 | - if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { |
156 | - gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0); | 156 | + if (freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) { |
157 | - neon_store_reg(rd, pass, tmp); | 157 | if (s->cr & CR_ENMOD) { |
158 | - } /* for pass */ | 158 | if (s->cr & CR_RLD) { |
159 | - tcg_temp_free_i64(tmp64); | 159 | ptimer_set_limit(s->timer_reload, s->lr, 1); |
160 | - } else { | 160 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps imx_epit_ops = { |
161 | - if (size == 1) { | 161 | |
162 | - imm = (uint16_t)shift; | 162 | static const VMStateDescription vmstate_imx_timer_epit = { |
163 | - imm |= imm << 16; | 163 | .name = TYPE_IMX_EPIT, |
164 | - } else { | 164 | - .version_id = 2, |
165 | - /* size == 2 */ | 165 | - .minimum_version_id = 2, |
166 | - imm = (uint32_t)shift; | 166 | + .version_id = 3, |
167 | - } | 167 | + .minimum_version_id = 3, |
168 | - tmp2 = tcg_const_i32(imm); | 168 | .fields = (VMStateField[]) { |
169 | - tmp4 = neon_load_reg(rm + 1, 0); | 169 | VMSTATE_UINT32(cr, IMXEPITState), |
170 | - tmp5 = neon_load_reg(rm + 1, 1); | 170 | VMSTATE_UINT32(sr, IMXEPITState), |
171 | - for (pass = 0; pass < 2; pass++) { | 171 | VMSTATE_UINT32(lr, IMXEPITState), |
172 | - if (pass == 0) { | 172 | VMSTATE_UINT32(cmp, IMXEPITState), |
173 | - tmp = neon_load_reg(rm, 0); | 173 | - VMSTATE_UINT32(cnt, IMXEPITState), |
174 | - } else { | 174 | - VMSTATE_UINT32(freq, IMXEPITState), |
175 | - tmp = tmp4; | 175 | VMSTATE_PTIMER(timer_reload, IMXEPITState), |
176 | - } | 176 | VMSTATE_PTIMER(timer_cmp, IMXEPITState), |
177 | - gen_neon_shift_narrow(size, tmp, tmp2, q, | 177 | VMSTATE_END_OF_LIST() |
178 | - input_unsigned); | ||
179 | - if (pass == 0) { | ||
180 | - tmp3 = neon_load_reg(rm, 1); | ||
181 | - } else { | ||
182 | - tmp3 = tmp5; | ||
183 | - } | ||
184 | - gen_neon_shift_narrow(size, tmp3, tmp2, q, | ||
185 | - input_unsigned); | ||
186 | - tcg_gen_concat_i32_i64(cpu_V0, tmp, tmp3); | ||
187 | - tcg_temp_free_i32(tmp); | ||
188 | - tcg_temp_free_i32(tmp3); | ||
189 | - tmp = tcg_temp_new_i32(); | ||
190 | - gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0); | ||
191 | - neon_store_reg(rd, pass, tmp); | ||
192 | - } /* for pass */ | ||
193 | - tcg_temp_free_i32(tmp2); | ||
194 | - } | ||
195 | - } else if (op == 10) { | ||
196 | + if (op == 10) { | ||
197 | /* VSHLL, VMOVL */ | ||
198 | if (q || (rd & 1)) { | ||
199 | return 1; | ||
200 | -- | 178 | -- |
201 | 2.20.1 | 179 | 2.25.1 |
202 | |||
203 | diff view generated by jsdifflib |
1 | Convert the VSHL and VSLI insns from the Neon 2-registers-and-a-shift | 1 | From: Axel Heider <axel.heider@hensoldt.net> |
---|---|---|---|
2 | group to decodetree. | ||
3 | 2 | ||
3 | - fix #1263 for CR writes | ||
4 | - rework compare time handling | ||
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. | ||
12 | |||
13 | Signed-off-by: Axel Heider <axel.heider@hensoldt.net> | ||
14 | [PMM: fixed minor style nits] | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200522145520.6778-2-peter.maydell@linaro.org | ||
7 | --- | 17 | --- |
8 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++++ | 18 | hw/timer/imx_epit.c | 192 ++++++++++++++++++++++++++------------------ |
9 | target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++ | 19 | 1 file changed, 116 insertions(+), 76 deletions(-) |
10 | target/arm/translate.c | 18 +++++++--------- | ||
11 | 3 files changed, 71 insertions(+), 10 deletions(-) | ||
12 | 20 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
14 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 23 | --- a/hw/timer/imx_epit.c |
16 | +++ b/target/arm/neon-dp.decode | 24 | +++ b/hw/timer/imx_epit.c |
17 | @@ -XXX,XX +XXX,XX @@ VRECPS_fp_3s 1111 001 0 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | 25 | @@ -XXX,XX +XXX,XX @@ |
18 | VRSQRTS_fp_3s 1111 001 0 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 26 | * Originally written by Hans Jiang |
19 | VMAXNM_fp_3s 1111 001 1 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | 27 | * Updated by Peter Chubb |
20 | VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 28 | * Updated by Jean-Christophe Dubois <jcd@tribudubois.net> |
21 | + | 29 | + * Updated by Axel Heider |
22 | +###################################################################### | 30 | * |
23 | +# 2-reg-and-shift grouping: | 31 | * This code is licensed under GPL version 2 or later. See |
24 | +# 1111 001 U 1 D immH:3 immL:3 Vd:4 opc:4 L Q M 1 Vm:4 | 32 | * the COPYING file in the top-level directory. |
25 | +###################################################################### | 33 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size) |
26 | +&2reg_shift vm vd q shift size | 34 | return reg_value; |
27 | + | 35 | } |
28 | +@2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | 36 | |
29 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | 37 | -/* Must be called from ptimer_transaction_begin/commit block for s->timer_cmp */ |
30 | +@2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | 38 | -static void imx_epit_reload_compare_timer(IMXEPITState *s) |
31 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 | 39 | +/* |
32 | +@2reg_shl_h .... ... . . . 01 shift:4 .... .... 0 q:1 . . .... \ | 40 | + * Must be called from a ptimer_transaction_begin/commit block for |
33 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 | 41 | + * s->timer_cmp, but outside of a transaction block of s->timer_reload, |
34 | +@2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 42 | + * so the proper counter value is read. |
35 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 43 | + */ |
36 | + | 44 | +static void imx_epit_update_compare_timer(IMXEPITState *s) |
37 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 45 | { |
38 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 46 | - if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN)) { |
39 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 47 | - /* if the compare feature is on and timers are running */ |
40 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | 48 | - uint32_t tmp = ptimer_get_count(s->timer_reload); |
41 | + | 49 | - uint64_t next; |
42 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 50 | - if (tmp > s->cmp) { |
43 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 51 | - /* It'll fire in this round of the timer */ |
44 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 52 | - next = tmp - s->cmp; |
45 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | 53 | - } else { /* catch it next time around */ |
46 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 54 | - next = tmp - s->cmp + ((s->cr & CR_RLD) ? EPIT_TIMER_MAX : s->lr); |
47 | index XXXXXXX..XXXXXXX 100644 | 55 | + uint64_t counter = 0; |
48 | --- a/target/arm/translate-neon.inc.c | 56 | + bool is_oneshot = false; |
49 | +++ b/target/arm/translate-neon.inc.c | 57 | + /* |
50 | @@ -XXX,XX +XXX,XX @@ static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn) | 58 | + * The compare timer only has to run if the timer peripheral is active |
51 | DO_3S_FP_PAIR(VPADD, gen_helper_vfp_adds) | 59 | + * and there is an input clock, Otherwise it can be switched off. |
52 | DO_3S_FP_PAIR(VPMAX, gen_helper_vfp_maxs) | 60 | + */ |
53 | DO_3S_FP_PAIR(VPMIN, gen_helper_vfp_mins) | 61 | + bool is_active = (s->cr & CR_EN) && imx_epit_get_freq(s); |
54 | + | 62 | + if (is_active) { |
55 | +static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | 63 | + /* |
56 | +{ | 64 | + * Calculate next timeout for compare timer. Reading the reload |
57 | + /* Handle a 2-reg-shift insn which can be vectorized. */ | 65 | + * counter returns proper results only if pending transactions |
58 | + int vec_size = a->q ? 16 : 8; | 66 | + * on it are committed here. Otherwise stale values are be read. |
59 | + int rd_ofs = neon_reg_offset(a->vd, 0); | 67 | + */ |
60 | + int rm_ofs = neon_reg_offset(a->vm, 0); | 68 | + counter = ptimer_get_count(s->timer_reload); |
61 | + | 69 | + uint64_t limit = ptimer_get_limit(s->timer_cmp); |
62 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 70 | + /* |
63 | + return false; | 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); | ||
64 | + } | 114 | + } |
65 | + | 115 | + |
66 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 116 | } |
67 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 117 | |
68 | + ((a->vd | a->vm) & 0x10)) { | 118 | static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) |
69 | + return false; | 119 | { |
70 | + } | 120 | - uint32_t freq = 0; |
71 | + | 121 | uint32_t oldcr = s->cr; |
72 | + if ((a->vm | a->vd) & a->q) { | 122 | |
73 | + return false; | 123 | s->cr = value & 0x03ffffff; |
74 | + } | 124 | |
75 | + | 125 | if (s->cr & CR_SWR) { |
76 | + if (!vfp_access_check(s)) { | 126 | - /* handle the reset */ |
77 | + return true; | 127 | + /* |
78 | + } | 128 | + * Reset clears CR.SWR again. It does not touch CR.EN, but the timers |
79 | + | 129 | + * are still stopped because the input clock is disabled. |
80 | + fn(a->size, rd_ofs, rm_ofs, a->shift, vec_size, vec_size); | 130 | + */ |
81 | + return true; | 131 | imx_epit_reset(s, false); |
82 | +} | 132 | + } else { |
83 | + | 133 | + uint32_t freq; |
84 | +#define DO_2SH(INSN, FUNC) \ | 134 | + uint32_t toggled_cr_bits = oldcr ^ s->cr; |
85 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | 135 | + /* re-initialize the limits if CR.RLD has changed */ |
86 | + { \ | 136 | + bool set_limit = toggled_cr_bits & CR_RLD; |
87 | + return do_vector_2sh(s, a, FUNC); \ | 137 | + /* set the counter if the timer got just enabled and CR.ENMOD is set */ |
88 | + } \ | 138 | + bool is_switched_on = (toggled_cr_bits & s->cr) & CR_EN; |
89 | + | 139 | + bool set_counter = is_switched_on && (s->cr & CR_ENMOD); |
90 | +DO_2SH(VSHL, tcg_gen_gvec_shli) | 140 | + |
91 | +DO_2SH(VSLI, gen_gvec_sli) | 141 | + ptimer_transaction_begin(s->timer_cmp); |
92 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 142 | + ptimer_transaction_begin(s->timer_reload); |
93 | index XXXXXXX..XXXXXXX 100644 | 143 | + freq = imx_epit_get_freq(s); |
94 | --- a/target/arm/translate.c | 144 | + if (freq) { |
95 | +++ b/target/arm/translate.c | 145 | + ptimer_set_freq(s->timer_reload, freq); |
96 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 146 | + ptimer_set_freq(s->timer_cmp, freq); |
97 | if ((insn & 0x00380080) != 0) { | 147 | + } |
98 | /* Two registers and shift. */ | 148 | + |
99 | op = (insn >> 8) & 0xf; | 149 | + if (set_limit || set_counter) { |
100 | + | 150 | + uint64_t limit = (s->cr & CR_RLD) ? s->lr : EPIT_TIMER_MAX; |
101 | + switch (op) { | 151 | + ptimer_set_limit(s->timer_reload, limit, set_counter ? 1 : 0); |
102 | + case 5: /* VSHL, VSLI */ | 152 | + if (set_limit) { |
103 | + return 1; /* handled by decodetree */ | 153 | + ptimer_set_limit(s->timer_cmp, limit, 0); |
104 | + default: | ||
105 | + break; | ||
106 | + } | 154 | + } |
107 | + | 155 | + } |
108 | if (insn & (1 << 7)) { | 156 | + /* |
109 | /* 64-bit shift. */ | 157 | + * If there is an input clock and the peripheral is enabled, then |
110 | if (op > 7) { | 158 | + * ensure the wall clock timer is ticking. Otherwise stop the timers. |
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 159 | + * The compare timer will be updated later. |
112 | gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | 160 | + */ |
113 | vec_size, vec_size); | 161 | + if (freq && (s->cr & CR_EN)) { |
114 | return 0; | 162 | + ptimer_run(s->timer_reload, 0); |
115 | - | 163 | + } else { |
116 | - case 5: /* VSHL, VSLI */ | 164 | + ptimer_stop(s->timer_reload); |
117 | - if (u) { /* VSLI */ | 165 | + } |
118 | - gen_gvec_sli(size, rd_ofs, rm_ofs, shift, | 166 | + /* Commit changes to reload timer, so they can propagate. */ |
119 | - vec_size, vec_size); | 167 | + ptimer_transaction_commit(s->timer_reload); |
120 | - } else { /* VSHL */ | 168 | + /* Update compare timer based on the committed reload timer value. */ |
121 | - tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, | 169 | + imx_epit_update_compare_timer(s); |
122 | - vec_size, vec_size); | 170 | + ptimer_transaction_commit(s->timer_cmp); |
123 | - } | 171 | } |
124 | - return 0; | 172 | |
125 | } | 173 | /* |
126 | 174 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cr(IMXEPITState *s, uint32_t value) | |
127 | if (size == 3) { | 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; | ||
128 | -- | 274 | -- |
129 | 2.20.1 | 275 | 2.25.1 |
130 | |||
131 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 3 | Fix these: |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | |
5 | Message-id: 20200602135050.593692-1-clg@kaod.org | 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 | ||
8 | |||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Reviewed-by: Claudio Fontana <cfontana@suse.de> | ||
11 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
12 | Message-id: 20221213190537.511-2-farosas@suse.de | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 14 | --- |
8 | docs/system/arm/aspeed.rst | 85 ++++++++++++++++++++++++++++++++++++++ | 15 | target/arm/helper.c | 323 +++++++++++++++++++++++++++++--------------- |
9 | docs/system/target-arm.rst | 1 + | 16 | 1 file changed, 215 insertions(+), 108 deletions(-) |
10 | 2 files changed, 86 insertions(+) | ||
11 | create mode 100644 docs/system/arm/aspeed.rst | ||
12 | 17 | ||
13 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 18 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | new file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- /dev/null | ||
17 | +++ b/docs/system/arm/aspeed.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | +Aspeed family boards (``*-bmc``, ``ast2500-evb``, ``ast2600-evb``) | ||
20 | +================================================================== | ||
21 | + | ||
22 | +The QEMU Aspeed machines model BMCs of various OpenPOWER systems and | ||
23 | +Aspeed evaluation boards. They are based on different releases of the | ||
24 | +Aspeed SoC : the AST2400 integrating an ARM926EJ-S CPU (400MHz), the | ||
25 | +AST2500 with an ARM1176JZS CPU (800MHz) and more recently the AST2600 | ||
26 | +with dual cores ARM Cortex A7 CPUs (1.2GHz). | ||
27 | + | ||
28 | +The SoC comes with RAM, Gigabit ethernet, USB, SD/MMC, USB, SPI, I2C, | ||
29 | +etc. | ||
30 | + | ||
31 | +AST2400 SoC based machines : | ||
32 | + | ||
33 | +- ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | ||
34 | + | ||
35 | +AST2500 SoC based machines : | ||
36 | + | ||
37 | +- ``ast2500-evb`` Aspeed AST2500 Evaluation board | ||
38 | +- ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC | ||
39 | +- ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC | ||
40 | +- ``sonorapass-bmc`` OCP SonoraPass BMC | ||
41 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 | ||
42 | + | ||
43 | +AST2600 SoC based machines : | ||
44 | + | ||
45 | +- ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex A7) | ||
46 | +- ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
47 | + | ||
48 | +Supported devices | ||
49 | +----------------- | ||
50 | + | ||
51 | + * SMP (for the AST2600 Cortex-A7) | ||
52 | + * Interrupt Controller (VIC) | ||
53 | + * Timer Controller | ||
54 | + * RTC Controller | ||
55 | + * I2C Controller | ||
56 | + * System Control Unit (SCU) | ||
57 | + * SRAM mapping | ||
58 | + * X-DMA Controller (basic interface) | ||
59 | + * Static Memory Controller (SMC or FMC) - Only SPI Flash support | ||
60 | + * SPI Memory Controller | ||
61 | + * USB 2.0 Controller | ||
62 | + * SD/MMC storage controllers | ||
63 | + * SDRAM controller (dummy interface for basic settings and training) | ||
64 | + * Watchdog Controller | ||
65 | + * GPIO Controller (Master only) | ||
66 | + * UART | ||
67 | + * Ethernet controllers | ||
68 | + | ||
69 | + | ||
70 | +Missing devices | ||
71 | +--------------- | ||
72 | + | ||
73 | + * Coprocessor support | ||
74 | + * ADC (out of tree implementation) | ||
75 | + * PWM and Fan Controller | ||
76 | + * LPC Bus Controller | ||
77 | + * Slave GPIO Controller | ||
78 | + * Super I/O Controller | ||
79 | + * Hash/Crypto Engine | ||
80 | + * PCI-Express 1 Controller | ||
81 | + * Graphic Display Controller | ||
82 | + * PECI Controller | ||
83 | + * MCTP Controller | ||
84 | + * Mailbox Controller | ||
85 | + * Virtual UART | ||
86 | + * eSPI Controller | ||
87 | + * I3C Controller | ||
88 | + | ||
89 | +Boot options | ||
90 | +------------ | ||
91 | + | ||
92 | +The Aspeed machines can be started using the -kernel option to load a | ||
93 | +Linux kernel or from a firmare image which can be downloaded from the | ||
94 | +OpenPOWER jenkins : | ||
95 | + | ||
96 | + https://openpower.xyz/ | ||
97 | + | ||
98 | +The image should be attached as an MTD drive. Run : | ||
99 | + | ||
100 | +.. code-block:: bash | ||
101 | + | ||
102 | + $ qemu-system-arm -M romulus-bmc -nic user \ | ||
103 | + -drive file=flash-romulus,format=raw,if=mtd -nographic | ||
104 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
105 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
106 | --- a/docs/system/target-arm.rst | 20 | --- a/target/arm/helper.c |
107 | +++ b/docs/system/target-arm.rst | 21 | +++ b/target/arm/helper.c |
108 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | 22 | @@ -XXX,XX +XXX,XX @@ uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri) |
109 | arm/realview | 23 | static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, |
110 | arm/versatile | 24 | uint64_t v) |
111 | arm/vexpress | 25 | { |
112 | + arm/aspeed | 26 | - /* Raw write of a coprocessor register (as needed for migration, etc). |
113 | arm/musicpal | 27 | + /* |
114 | arm/nseries | 28 | + * Raw write of a coprocessor register (as needed for migration, etc). |
115 | arm/orangepi | 29 | * Note that constant registers are treated as write-ignored; the |
30 | * caller should check for success by whether a readback gives the | ||
31 | * value written. | ||
32 | @@ -XXX,XX +XXX,XX @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri, | ||
33 | |||
34 | static bool raw_accessors_invalid(const ARMCPRegInfo *ri) | ||
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; | ||
281 | } else { | ||
282 | - /* We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR | ||
283 | - * are CONSTRAINED UNPREDICTABLE. */ | ||
284 | + /* | ||
285 | + * We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR | ||
286 | + * are CONSTRAINED UNPREDICTABLE. | ||
287 | + */ | ||
288 | return 0; | ||
289 | } | ||
290 | } | ||
291 | @@ -XXX,XX +XXX,XX @@ static void pmintenclr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
292 | static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
293 | uint64_t value) | ||
294 | { | ||
295 | - /* Note that even though the AArch64 view of this register has bits | ||
296 | + /* | ||
297 | + * Note that even though the AArch64 view of this register has bits | ||
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; | ||
409 | } | ||
410 | - /* Note that the desired next expiry time might be beyond the | ||
411 | + /* | ||
412 | + * Note that the desired next expiry time might be beyond the | ||
413 | * signed-64-bit range of a QEMUTimer -- in this case we just | ||
414 | * set the timer for as far in the future as possible. When the | ||
415 | * timer expires we will reset the timer for any remaining period. | ||
416 | @@ -XXX,XX +XXX,XX @@ static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
417 | /* Enable toggled */ | ||
418 | gt_recalc_timer(cpu, timeridx); | ||
419 | } else if ((oldval ^ value) & 2) { | ||
420 | - /* IMASK toggled: don't need to recalculate, | ||
421 | + /* | ||
422 | + * IMASK toggled: don't need to recalculate, | ||
423 | * just set the interrupt line based on ISTATUS | ||
424 | */ | ||
425 | int irqstate = (oldval & 4) && !(value & 2); | ||
426 | @@ -XXX,XX +XXX,XX @@ static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaque) | ||
427 | } | ||
428 | |||
429 | static const ARMCPRegInfo generic_timer_cp_reginfo[] = { | ||
430 | - /* Note that CNTFRQ is purely reads-as-written for the benefit | ||
431 | + /* | ||
432 | + * Note that CNTFRQ is purely reads-as-written for the benefit | ||
433 | * of software; writing it doesn't actually change the timer frequency. | ||
434 | * Our reset value matches the fixed frequency we implement the timer at. | ||
435 | */ | ||
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, | ||
477 | } | ||
478 | } | ||
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 | ||
116 | -- | 1057 | -- |
117 | 2.20.1 | 1058 | 2.25.1 |
118 | |||
119 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Fabiano Rosas <farosas@suse.de> | ||
1 | 2 | ||
3 | Fix the following: | ||
4 | |||
5 | ERROR: spaces required around that '|' (ctx:VxV) | ||
6 | ERROR: space required before the open parenthesis '(' | ||
7 | ERROR: spaces required around that '+' (ctx:VxB) | ||
8 | ERROR: space prohibited between function name and open parenthesis '(' | ||
9 | |||
10 | (the last two still have some occurrences in macros which I left | ||
11 | behind because it might impact readability) | ||
12 | |||
13 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
14 | Reviewed-by: Claudio Fontana <cfontana@suse.de> | ||
15 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
16 | Message-id: 20221213190537.511-3-farosas@suse.de | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | target/arm/helper.c | 42 +++++++++++++++++++++--------------------- | ||
20 | 1 file changed, 21 insertions(+), 21 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/helper.c | ||
25 | +++ b/target/arm/helper.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque) | ||
27 | uint32_t regidx = (uintptr_t)key; | ||
28 | const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx); | ||
29 | |||
30 | - if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
31 | + if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) { | ||
32 | cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx); | ||
33 | /* The value array need not be initialized at this point */ | ||
34 | cpu->cpreg_array_len++; | ||
35 | @@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque) | ||
36 | |||
37 | ri = g_hash_table_lookup(cpu->cp_regs, key); | ||
38 | |||
39 | - if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) { | ||
40 | + if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) { | ||
41 | cpu->cpreg_array_len++; | ||
42 | } | ||
43 | } | ||
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = { | ||
45 | .resetfn = arm_cp_reset_ignore }, | ||
46 | { .name = "TPIDRRO_EL0", .state = ARM_CP_STATE_AA64, | ||
47 | .opc0 = 3, .opc1 = 3, .opc2 = 3, .crn = 13, .crm = 0, | ||
48 | - .access = PL0_R|PL1_W, | ||
49 | + .access = PL0_R | PL1_W, | ||
50 | .fieldoffset = offsetof(CPUARMState, cp15.tpidrro_el[0]), | ||
51 | .resetvalue = 0}, | ||
52 | { .name = "TPIDRURO", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 3, | ||
53 | - .access = PL0_R|PL1_W, | ||
54 | + .access = PL0_R | PL1_W, | ||
55 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidruro_s), | ||
56 | offsetoflow32(CPUARMState, cp15.tpidruro_ns) }, | ||
57 | .resetfn = arm_cp_reset_ignore }, | ||
58 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = { | ||
59 | .resetvalue = 0 }, | ||
60 | /* The cache ops themselves: these all NOP for QEMU */ | ||
61 | { .name = "IICR", .cp = 15, .crm = 5, .opc1 = 0, | ||
62 | - .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
63 | + .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, | ||
64 | { .name = "IDCR", .cp = 15, .crm = 6, .opc1 = 0, | ||
65 | - .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
66 | + .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, | ||
67 | { .name = "CDCR", .cp = 15, .crm = 12, .opc1 = 0, | ||
68 | - .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
69 | + .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, | ||
70 | { .name = "PIR", .cp = 15, .crm = 12, .opc1 = 1, | ||
71 | - .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
72 | + .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, | ||
73 | { .name = "PDR", .cp = 15, .crm = 12, .opc1 = 2, | ||
74 | - .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
75 | + .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, | ||
76 | { .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0, | ||
77 | - .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT }, | ||
78 | + .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT }, | ||
79 | }; | ||
80 | |||
81 | static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = { | ||
82 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
83 | ARMCPRegInfo cbar = { | ||
84 | .name = "CBAR", | ||
85 | .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0, | ||
86 | - .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar, | ||
87 | + .access = PL1_R | PL3_W, .resetvalue = cpu->reset_cbar, | ||
88 | .fieldoffset = offsetof(CPUARMState, | ||
89 | cp15.c15_config_base_address) | ||
90 | }; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) | ||
92 | return; | ||
93 | |||
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 | ||
161 | -- | ||
162 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | Fix this: |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | ERROR: braces {} are necessary for all arms of this statement |
5 | an existing bug vs SVE. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
8 | Message-id: 20200514212831.31248-4-richard.henderson@linaro.org | 7 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
9 | Message-id: 20221213190537.511-4-farosas@suse.de | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/helper.h | 15 +++++++----- | 12 | target/arm/helper.c | 67 ++++++++++++++++++++++++++++----------------- |
13 | target/arm/crypto_helper.c | 37 +++++++++++++++++++++++----- | 13 | 1 file changed, 42 insertions(+), 25 deletions(-) |
14 | target/arm/translate-a64.c | 50 ++++++++++++-------------------------- | ||
15 | 3 files changed, 55 insertions(+), 47 deletions(-) | ||
16 | 14 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 17 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper.h | 18 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, |
22 | DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 20 | env->CF = (val >> 29) & 1; |
23 | DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 21 | env->VF = (val << 3) & 0x80000000; |
24 | 22 | } | |
25 | -DEF_HELPER_FLAGS_3(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 23 | - if (mask & CPSR_Q) |
26 | -DEF_HELPER_FLAGS_3(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 24 | + if (mask & CPSR_Q) { |
27 | -DEF_HELPER_FLAGS_2(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 25 | env->QF = ((val & CPSR_Q) != 0); |
28 | -DEF_HELPER_FLAGS_3(crypto_sha512su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 26 | - if (mask & CPSR_T) |
29 | +DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 27 | + } |
30 | +DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 28 | + if (mask & CPSR_T) { |
31 | +DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 29 | env->thumb = ((val & CPSR_T) != 0); |
32 | +DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | 30 | + } |
33 | + void, ptr, ptr, ptr, i32) | 31 | if (mask & CPSR_IT_0_1) { |
34 | 32 | env->condexec_bits &= ~3; | |
35 | DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | 33 | env->condexec_bits |= (val >> 25) & 3; |
36 | -DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 34 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) |
37 | -DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 35 | int i; |
38 | +DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | 36 | |
39 | + void, ptr, ptr, ptr, i32) | 37 | old_mode = env->uncached_cpsr & CPSR_M; |
40 | +DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | 38 | - if (mode == old_mode) |
41 | + void, ptr, ptr, ptr, i32) | 39 | + if (mode == old_mode) { |
42 | 40 | return; | |
43 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 41 | + } |
44 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 42 | |
45 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | 43 | if (old_mode == ARM_CPU_MODE_FIQ) { |
46 | index XXXXXXX..XXXXXXX 100644 | 44 | memcpy(env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t)); |
47 | --- a/target/arm/crypto_helper.c | 45 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) |
48 | +++ b/target/arm/crypto_helper.c | 46 | new_mode = ARM_CPU_MODE_UND; |
49 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 47 | addr = 0x04; |
50 | #define CR_ST_WORD(state, i) (state.words[i]) | 48 | mask = CPSR_I; |
51 | #endif | 49 | - if (env->thumb) |
52 | 50 | + if (env->thumb) { | |
53 | +/* | 51 | offset = 2; |
54 | + * The caller has not been converted to full gvec, and so only | 52 | - else |
55 | + * modifies the low 16 bytes of the vector register. | 53 | + } else { |
56 | + */ | 54 | offset = 4; |
57 | +static void clear_tail_16(void *vd, uint32_t desc) | 55 | + } |
58 | +{ | 56 | break; |
59 | + int opr_sz = simd_oprsz(desc); | 57 | case EXCP_SWI: |
60 | + int max_sz = simd_maxsz(desc); | 58 | new_mode = ARM_CPU_MODE_SVC; |
61 | + | 59 | @@ -XXX,XX +XXX,XX @@ static inline uint16_t add16_sat(uint16_t a, uint16_t b) |
62 | + assert(opr_sz == 16); | 60 | |
63 | + clear_tail(vd, opr_sz, max_sz); | 61 | res = a + b; |
64 | +} | 62 | if (((res ^ a) & 0x8000) && !((a ^ b) & 0x8000)) { |
65 | + | 63 | - if (a & 0x8000) |
66 | static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | 64 | + if (a & 0x8000) { |
67 | uint64_t *rm, bool decrypt) | 65 | res = 0x8000; |
66 | - else | ||
67 | + } else { | ||
68 | res = 0x7fff; | ||
69 | + } | ||
70 | } | ||
71 | return res; | ||
72 | } | ||
73 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t add8_sat(uint8_t a, uint8_t b) | ||
74 | |||
75 | res = a + b; | ||
76 | if (((res ^ a) & 0x80) && !((a ^ b) & 0x80)) { | ||
77 | - if (a & 0x80) | ||
78 | + if (a & 0x80) { | ||
79 | res = 0x80; | ||
80 | - else | ||
81 | + } else { | ||
82 | res = 0x7f; | ||
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) | ||
68 | { | 116 | { |
69 | @@ -XXX,XX +XXX,XX @@ static uint64_t s1_512(uint64_t x) | 117 | uint16_t res; |
70 | return ror64(x, 19) ^ ror64(x, 61) ^ (x >> 6); | 118 | res = a + b; |
119 | - if (res < a) | ||
120 | + if (res < a) { | ||
121 | res = 0xffff; | ||
122 | + } | ||
123 | return res; | ||
71 | } | 124 | } |
72 | 125 | ||
73 | -void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 126 | static inline uint16_t sub16_usat(uint16_t a, uint16_t b) |
74 | +void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
75 | { | 127 | { |
76 | uint64_t *rd = vd; | 128 | - if (a > b) |
77 | uint64_t *rn = vn; | 129 | + if (a > b) { |
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 130 | return a - b; |
79 | 131 | - else | |
80 | rd[0] = d0; | 132 | + } else { |
81 | rd[1] = d1; | 133 | return 0; |
82 | + | 134 | + } |
83 | + clear_tail_16(vd, desc); | ||
84 | } | 135 | } |
85 | 136 | ||
86 | -void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | 137 | static inline uint8_t add8_usat(uint8_t a, uint8_t b) |
87 | +void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
88 | { | 138 | { |
89 | uint64_t *rd = vd; | 139 | uint8_t res; |
90 | uint64_t *rn = vn; | 140 | res = a + b; |
91 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | 141 | - if (res < a) |
92 | 142 | + if (res < a) { | |
93 | rd[0] = d0; | 143 | res = 0xff; |
94 | rd[1] = d1; | 144 | + } |
95 | + | 145 | return res; |
96 | + clear_tail_16(vd, desc); | ||
97 | } | 146 | } |
98 | 147 | ||
99 | -void HELPER(crypto_sha512su0)(void *vd, void *vn) | 148 | static inline uint8_t sub8_usat(uint8_t a, uint8_t b) |
100 | +void HELPER(crypto_sha512su0)(void *vd, void *vn, uint32_t desc) | ||
101 | { | 149 | { |
102 | uint64_t *rd = vd; | 150 | - if (a > b) |
103 | uint64_t *rn = vn; | 151 | + if (a > b) { |
104 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su0)(void *vd, void *vn) | 152 | return a - b; |
105 | 153 | - else | |
106 | rd[0] = d0; | 154 | + } else { |
107 | rd[1] = d1; | 155 | return 0; |
108 | + | 156 | + } |
109 | + clear_tail_16(vd, desc); | ||
110 | } | 157 | } |
111 | 158 | ||
112 | -void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | 159 | #define ADD16(a, b, n) RESULT(add16_usat(a, b), n, 16); |
113 | +void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm, uint32_t desc) | 160 | @@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b) |
161 | |||
162 | static inline uint8_t do_usad(uint8_t a, uint8_t b) | ||
114 | { | 163 | { |
115 | uint64_t *rd = vd; | 164 | - if (a > b) |
116 | uint64_t *rn = vn; | 165 | + if (a > b) { |
117 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | 166 | return a - b; |
118 | 167 | - else | |
119 | rd[0] += s1_512(rn[0]) + rm[0]; | 168 | + } else { |
120 | rd[1] += s1_512(rn[1]) + rm[1]; | 169 | return b - a; |
121 | + | 170 | + } |
122 | + clear_tail_16(vd, desc); | ||
123 | } | 171 | } |
124 | 172 | ||
125 | -void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | 173 | /* Unsigned sum of absolute byte differences. */ |
126 | +void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm, uint32_t desc) | 174 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b) |
127 | { | 175 | uint32_t mask; |
128 | uint64_t *rd = vd; | 176 | |
129 | uint64_t *rn = vn; | 177 | mask = 0; |
130 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | 178 | - if (flags & 1) |
131 | 179 | + if (flags & 1) { | |
132 | rd[0] = d.l[0]; | 180 | mask |= 0xff; |
133 | rd[1] = d.l[1]; | 181 | - if (flags & 2) |
134 | + | 182 | + } |
135 | + clear_tail_16(vd, desc); | 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); | ||
136 | } | 195 | } |
137 | 196 | ||
138 | -void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm) | ||
139 | +void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
140 | { | ||
141 | uint64_t *rd = vd; | ||
142 | uint64_t *rn = vn; | ||
143 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm) | ||
144 | |||
145 | rd[0] = d.l[0]; | ||
146 | rd[1] = d.l[1]; | ||
147 | + | ||
148 | + clear_tail_16(vd, desc); | ||
149 | } | ||
150 | |||
151 | void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
152 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate-a64.c | ||
155 | +++ b/target/arm/translate-a64.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
157 | int rn = extract32(insn, 5, 5); | ||
158 | int rd = extract32(insn, 0, 5); | ||
159 | bool feature; | ||
160 | - CryptoThreeOpFn *genfn = NULL; | ||
161 | gen_helper_gvec_3 *oolfn = NULL; | ||
162 | GVecGen3Fn *gvecfn = NULL; | ||
163 | |||
164 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
165 | switch (opcode) { | ||
166 | case 0: /* SHA512H */ | ||
167 | feature = dc_isar_feature(aa64_sha512, s); | ||
168 | - genfn = gen_helper_crypto_sha512h; | ||
169 | + oolfn = gen_helper_crypto_sha512h; | ||
170 | break; | ||
171 | case 1: /* SHA512H2 */ | ||
172 | feature = dc_isar_feature(aa64_sha512, s); | ||
173 | - genfn = gen_helper_crypto_sha512h2; | ||
174 | + oolfn = gen_helper_crypto_sha512h2; | ||
175 | break; | ||
176 | case 2: /* SHA512SU1 */ | ||
177 | feature = dc_isar_feature(aa64_sha512, s); | ||
178 | - genfn = gen_helper_crypto_sha512su1; | ||
179 | + oolfn = gen_helper_crypto_sha512su1; | ||
180 | break; | ||
181 | case 3: /* RAX1 */ | ||
182 | feature = dc_isar_feature(aa64_sha3, s); | ||
183 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
184 | switch (opcode) { | ||
185 | case 0: /* SM3PARTW1 */ | ||
186 | feature = dc_isar_feature(aa64_sm3, s); | ||
187 | - genfn = gen_helper_crypto_sm3partw1; | ||
188 | + oolfn = gen_helper_crypto_sm3partw1; | ||
189 | break; | ||
190 | case 1: /* SM3PARTW2 */ | ||
191 | feature = dc_isar_feature(aa64_sm3, s); | ||
192 | - genfn = gen_helper_crypto_sm3partw2; | ||
193 | + oolfn = gen_helper_crypto_sm3partw2; | ||
194 | break; | ||
195 | case 2: /* SM4EKEY */ | ||
196 | feature = dc_isar_feature(aa64_sm4, s); | ||
197 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
198 | |||
199 | if (oolfn) { | ||
200 | gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
201 | - } else if (gvecfn) { | ||
202 | - gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
203 | } else { | ||
204 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
205 | - | ||
206 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
207 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
208 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
209 | - | ||
210 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | ||
211 | - | ||
212 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
213 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
214 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
215 | + gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
220 | int opcode = extract32(insn, 10, 2); | ||
221 | int rn = extract32(insn, 5, 5); | ||
222 | int rd = extract32(insn, 0, 5); | ||
223 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
224 | bool feature; | ||
225 | - CryptoTwoOpFn *genfn; | ||
226 | - gen_helper_gvec_3 *oolfn = NULL; | ||
227 | |||
228 | switch (opcode) { | ||
229 | case 0: /* SHA512SU0 */ | ||
230 | feature = dc_isar_feature(aa64_sha512, s); | ||
231 | - genfn = gen_helper_crypto_sha512su0; | ||
232 | break; | ||
233 | case 1: /* SM4E */ | ||
234 | feature = dc_isar_feature(aa64_sm4, s); | ||
235 | - oolfn = gen_helper_crypto_sm4e; | ||
236 | break; | ||
237 | default: | ||
238 | unallocated_encoding(s); | ||
239 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | - if (oolfn) { | ||
244 | - gen_gvec_op3_ool(s, true, rd, rd, rn, 0, oolfn); | ||
245 | - return; | ||
246 | + switch (opcode) { | ||
247 | + case 0: /* SHA512SU0 */ | ||
248 | + gen_gvec_op2_ool(s, true, rd, rn, 0, gen_helper_crypto_sha512su0); | ||
249 | + break; | ||
250 | + case 1: /* SM4E */ | ||
251 | + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, gen_helper_crypto_sm4e); | ||
252 | + break; | ||
253 | + default: | ||
254 | + g_assert_not_reached(); | ||
255 | } | ||
256 | - | ||
257 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
258 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
259 | - | ||
260 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | ||
261 | - | ||
262 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
263 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
264 | } | ||
265 | |||
266 | /* Crypto four-register | ||
267 | -- | 197 | -- |
268 | 2.20.1 | 198 | 2.25.1 |
269 | |||
270 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Fabiano Rosas <farosas@suse.de> | ||
1 | 2 | ||
3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
4 | Reviewed-by: Claudio Fontana <cfontana@suse.de> | ||
5 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
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(-) | ||
11 | |||
12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/m_helper.c | ||
15 | +++ b/target/arm/m_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | */ | ||
18 | |||
19 | #include "qemu/osdep.h" | ||
20 | -#include "qemu/units.h" | ||
21 | -#include "target/arm/idau.h" | ||
22 | -#include "trace.h" | ||
23 | #include "cpu.h" | ||
24 | #include "internals.h" | ||
25 | -#include "exec/gdbstub.h" | ||
26 | #include "exec/helper-proto.h" | ||
27 | -#include "qemu/host-utils.h" | ||
28 | #include "qemu/main-loop.h" | ||
29 | #include "qemu/bitops.h" | ||
30 | -#include "qemu/crc32c.h" | ||
31 | -#include "qemu/qemu-print.h" | ||
32 | #include "qemu/log.h" | ||
33 | #include "exec/exec-all.h" | ||
34 | -#include <zlib.h> /* For crc32 */ | ||
35 | -#include "semihosting/semihost.h" | ||
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" | ||
46 | #endif | ||
47 | -- | ||
48 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | hw_error() calls exit(). This a bit overkill when we can log | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
4 | the accesses as unimplemented or guest error. | 4 | Reviewed-by: Claudio Fontana <cfontana@suse.de> |
5 | 5 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | |
6 | When fuzzing the devices, we don't want the whole process to | 6 | Message-id: 20221213190537.511-6-farosas@suse.de |
7 | exit. Replace some hw_error() calls by qemu_log_mask() | ||
8 | (missed in commit 5a0001ec7e). | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20200525114123.21317-2-f4bug@amsat.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 8 | --- |
15 | hw/input/pxa2xx_keypad.c | 10 +++++++--- | 9 | target/arm/helper.c | 7 ------- |
16 | 1 file changed, 7 insertions(+), 3 deletions(-) | 10 | 1 file changed, 7 deletions(-) |
17 | 11 | ||
18 | diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/input/pxa2xx_keypad.c | 14 | --- a/target/arm/helper.c |
21 | +++ b/hw/input/pxa2xx_keypad.c | 15 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
23 | */ | 17 | */ |
24 | 18 | ||
25 | #include "qemu/osdep.h" | 19 | #include "qemu/osdep.h" |
26 | -#include "hw/hw.h" | 20 | -#include "qemu/units.h" |
27 | +#include "qemu/log.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 */ | ||
28 | #include "hw/irq.h" | 33 | #include "hw/irq.h" |
29 | #include "migration/vmstate.h" | 34 | -#include "semihosting/semihost.h" |
30 | #include "hw/arm/pxa.h" | 35 | -#include "sysemu/cpus.h" |
31 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr offset, | 36 | #include "sysemu/cpu-timers.h" |
32 | return s->kpkdi; | 37 | #include "sysemu/kvm.h" |
33 | break; | 38 | -#include "qemu/range.h" |
34 | default: | 39 | #include "qapi/qapi-commands-machine-target.h" |
35 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | 40 | #include "qapi/error.h" |
36 | + qemu_log_mask(LOG_GUEST_ERROR, | 41 | #include "qemu/guest-random.h" |
37 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 42 | #ifdef CONFIG_TCG |
38 | + __func__, offset); | 43 | -#include "arm_ldst.h" |
39 | } | 44 | -#include "exec/cpu_ldst.h" |
40 | 45 | #include "semihosting/common-semi.h" | |
41 | return 0; | 46 | #endif |
42 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_keypad_write(void *opaque, hwaddr offset, | 47 | #include "cpregs.h" |
43 | break; | ||
44 | |||
45 | default: | ||
46 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | ||
47 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
48 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
49 | + __func__, offset); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | -- | 48 | -- |
54 | 2.20.1 | 49 | 2.25.1 |
55 | |||
56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Claudio Fontana <cfontana@suse.de> | ||
1 | 2 | ||
3 | Remove some unused headers. | ||
4 | |||
5 | Signed-off-by: Claudio Fontana <cfontana@suse.de> | ||
6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Claudio Fontana <cfontana@suse.de> | ||
8 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Message-id: 20221213190537.511-7-farosas@suse.de | ||
11 | [added back some includes that are still needed at this point] | ||
12 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/cpu.c | 1 - | ||
16 | target/arm/cpu64.c | 6 ------ | ||
17 | 2 files changed, 7 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/cpu.c | ||
22 | +++ b/target/arm/cpu.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #include "target/arm/idau.h" | ||
25 | #include "qemu/module.h" | ||
26 | #include "qapi/error.h" | ||
27 | -#include "qapi/visitor.h" | ||
28 | #include "cpu.h" | ||
29 | #ifdef CONFIG_TCG | ||
30 | #include "hw/core/tcg-cpu-ops.h" | ||
31 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/cpu64.c | ||
34 | +++ b/target/arm/cpu64.c | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | #include "qemu/osdep.h" | ||
37 | #include "qapi/error.h" | ||
38 | #include "cpu.h" | ||
39 | -#ifdef CONFIG_TCG | ||
40 | -#include "hw/core/tcg-cpu-ops.h" | ||
41 | -#endif /* CONFIG_TCG */ | ||
42 | #include "qemu/module.h" | ||
43 | -#if !defined(CONFIG_USER_ONLY) | ||
44 | -#include "hw/loader.h" | ||
45 | -#endif | ||
46 | #include "sysemu/kvm.h" | ||
47 | #include "sysemu/hvf.h" | ||
48 | #include "kvm_arm.h" | ||
49 | -- | ||
50 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | As described by Edgar here: | 3 | The pointed MouseTransformInfo structure is accessed read-only. |
4 | 4 | ||
5 | https://www.mail-archive.com/qemu-devel@nongnu.org/msg605124.html | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
7 | we can use the Ubuntu kernel for testing the xlnx-versal-virt machine. | 7 | Message-id: 20221220142520.24094-2-philmd@linaro.org |
8 | So let's add a boot test for this now. | ||
9 | |||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
15 | Message-id: 20200525141237.15243-1-thuth@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 9 | --- |
18 | tests/acceptance/boot_linux_console.py | 26 ++++++++++++++++++++++++++ | 10 | include/hw/input/tsc2xxx.h | 4 ++-- |
19 | 1 file changed, 26 insertions(+) | 11 | hw/input/tsc2005.c | 2 +- |
12 | hw/input/tsc210x.c | 3 +-- | ||
13 | 3 files changed, 4 insertions(+), 5 deletions(-) | ||
20 | 14 | ||
21 | 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 |
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/tests/acceptance/boot_linux_console.py | 17 | --- a/include/hw/input/tsc2xxx.h |
24 | +++ b/tests/acceptance/boot_linux_console.py | 18 | +++ b/include/hw/input/tsc2xxx.h |
25 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 19 | @@ -XXX,XX +XXX,XX @@ uWireSlave *tsc2102_init(qemu_irq pint); |
26 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 20 | uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); |
27 | self.wait_for_console_pattern(console_pattern) | 21 | I2SCodec *tsc210x_codec(uWireSlave *chip); |
28 | 22 | uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | |
29 | + def test_aarch64_xlnx_versal_virt(self): | 23 | -void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info); |
30 | + """ | 24 | +void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info); |
31 | + :avocado: tags=arch:aarch64 | 25 | void tsc210x_key_event(uWireSlave *chip, int key, int down); |
32 | + :avocado: tags=machine:xlnx-versal-virt | 26 | |
33 | + :avocado: tags=device:pl011 | 27 | /* tsc2005.c */ |
34 | + :avocado: tags=device:arm_gicv3 | 28 | void *tsc2005_init(qemu_irq pintdav); |
35 | + """ | 29 | uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); |
36 | + kernel_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | 30 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); |
37 | + 'bionic-updates/main/installer-arm64/current/images/' | 31 | +void tsc2005_set_transform(void *opaque, const MouseTransformInfo *info); |
38 | + 'netboot/ubuntu-installer/arm64/linux') | 32 | |
39 | + kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50' | 33 | #endif |
40 | + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) | 34 | diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c |
41 | + | 35 | index XXXXXXX..XXXXXXX 100644 |
42 | + initrd_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | 36 | --- a/hw/input/tsc2005.c |
43 | + 'bionic-updates/main/installer-arm64/current/images/' | 37 | +++ b/hw/input/tsc2005.c |
44 | + 'netboot/ubuntu-installer/arm64/initrd.gz') | 38 | @@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav) |
45 | + initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772' | 39 | * from the touchscreen. Assuming 12-bit precision was used during |
46 | + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | 40 | * tslib calibration. |
47 | + | 41 | */ |
48 | + self.vm.set_console() | 42 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info) |
49 | + self.vm.add_args('-m', '2G', | 43 | +void tsc2005_set_transform(void *opaque, const MouseTransformInfo *info) |
50 | + '-kernel', kernel_path, | 44 | { |
51 | + '-initrd', initrd_path) | 45 | TSC2005State *s = (TSC2005State *) opaque; |
52 | + self.vm.launch() | 46 | |
53 | + self.wait_for_console_pattern('Checked W+X mappings: passed') | 47 | diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c |
54 | + | 48 | index XXXXXXX..XXXXXXX 100644 |
55 | def test_arm_virt(self): | 49 | --- a/hw/input/tsc210x.c |
56 | """ | 50 | +++ b/hw/input/tsc210x.c |
57 | :avocado: tags=arch:arm | 51 | @@ -XXX,XX +XXX,XX @@ I2SCodec *tsc210x_codec(uWireSlave *chip) |
52 | * from the touchscreen. Assuming 12-bit precision was used during | ||
53 | * tslib calibration. | ||
54 | */ | ||
55 | -void tsc210x_set_transform(uWireSlave *chip, | ||
56 | - MouseTransformInfo *info) | ||
57 | +void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info) | ||
58 | { | ||
59 | TSC210xState *s = (TSC210xState *) chip->opaque; | ||
60 | #if 0 | ||
58 | -- | 61 | -- |
59 | 2.20.1 | 62 | 2.25.1 |
60 | 63 | ||
61 | 64 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The while statement in question only checked if tx_burst is not 0. | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | tx_burst is a signed int, which is assigned the value put by the | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | guest driver in ECSPI_CONREG. The burst length can be anywhere | 5 | Message-id: 20221220142520.24094-3-philmd@linaro.org |
6 | between 1 and 4096, and since tx_burst is always decremented by 8 | ||
7 | it could possibly underflow, causing an infinite loop. | ||
8 | |||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 8 | hw/arm/nseries.c | 18 +++++++++--------- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 9 insertions(+), 9 deletions(-) |
15 | 10 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 13 | --- a/hw/arm/nseries.c |
19 | +++ b/hw/ssi/imx_spi.c | 14 | +++ b/hw/arm/nseries.c |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 15 | @@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s) |
21 | 16 | } | |
22 | rx = 0; | 17 | |
23 | 18 | /* Touchscreen and keypad controller */ | |
24 | - while (tx_burst) { | 19 | -static MouseTransformInfo n800_pointercal = { |
25 | + while (tx_burst > 0) { | 20 | +static const MouseTransformInfo n800_pointercal = { |
26 | uint8_t byte = tx & 0xff; | 21 | .x = 800, |
27 | 22 | .y = 480, | |
28 | DPRINTF("writing 0x%02x\n", (uint32_t)byte); | 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) | ||
75 | { | ||
76 | uint8_t *b; | ||
77 | uint16_t *w; | ||
78 | uint32_t *l; | ||
79 | - struct omap_gpiosw_info_s *gpiosw; | ||
80 | - struct omap_partition_info_s *partition; | ||
81 | + const struct omap_gpiosw_info_s *gpiosw; | ||
82 | + const struct omap_partition_info_s *partition; | ||
83 | const char *tag; | ||
84 | |||
85 | w = p; | ||
29 | -- | 86 | -- |
30 | 2.20.1 | 87 | 2.25.1 |
31 | 88 | ||
32 | 89 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With this conversion, we will be able to use the same helpers | 3 | Silent when compiling with -Wextra: |
4 | with sve. In particular, pass 3 vector parameters for the | ||
5 | 3-operand operations; for advsimd the destination register | ||
6 | is also an input. | ||
7 | 4 | ||
8 | This also fixes a bug in which we failed to clear the high bits | 5 | ../hw/arm/nseries.c:1081:12: warning: missing field 'line' initializer [-Wmissing-field-initializers] |
9 | of the SVE register after an AdvSIMD operation. | 6 | { NULL } |
7 | ^ | ||
10 | 8 | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Message-id: 20200514212831.31248-2-richard.henderson@linaro.org | 10 | Message-id: 20221220142520.24094-4-philmd@linaro.org |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 13 | --- |
16 | target/arm/helper.h | 6 ++-- | 14 | hw/arm/nseries.c | 10 ++++------ |
17 | target/arm/vec_internal.h | 33 +++++++++++++++++ | 15 | 1 file changed, 4 insertions(+), 6 deletions(-) |
18 | target/arm/crypto_helper.c | 72 +++++++++++++++++++++++++++----------- | ||
19 | target/arm/translate-a64.c | 55 ++++++++++++++++++----------- | ||
20 | target/arm/translate.c | 27 +++++++------- | ||
21 | target/arm/vec_helper.c | 12 +------ | ||
22 | 6 files changed, 138 insertions(+), 67 deletions(-) | ||
23 | create mode 100644 target/arm/vec_internal.h | ||
24 | 16 | ||
25 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 17 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
26 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.h | 19 | --- a/hw/arm/nseries.c |
28 | +++ b/target/arm/helper.h | 20 | +++ b/hw/arm/nseries.c |
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip8, TCG_CALL_NO_RWG, void, ptr, ptr) | 21 | @@ -XXX,XX +XXX,XX @@ static const struct omap_gpiosw_info_s { |
30 | DEF_HELPER_FLAGS_2(neon_qzip16, TCG_CALL_NO_RWG, void, ptr, ptr) | 22 | "headphone", N8X0_HEADPHONE_GPIO, |
31 | DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 23 | OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED, |
32 | 24 | }, | |
33 | -DEF_HELPER_FLAGS_3(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 25 | - { NULL } |
34 | +DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 26 | + { /* end of list */ } |
35 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 27 | }, n810_gpiosw_info[] = { |
36 | 28 | { | |
37 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 29 | "gps_reset", N810_GPS_RESET_GPIO, |
38 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | 30 | @@ -XXX,XX +XXX,XX @@ static const struct omap_gpiosw_info_s { |
39 | DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 31 | "slide", N810_SLIDE_GPIO, |
40 | DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 32 | OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED, |
41 | 33 | }, | |
42 | -DEF_HELPER_FLAGS_2(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr) | 34 | - { NULL } |
43 | -DEF_HELPER_FLAGS_3(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 35 | + { /* end of list */ } |
44 | +DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 36 | }; |
45 | +DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 37 | |
46 | 38 | static const struct omap_partition_info_s { | |
47 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 39 | @@ -XXX,XX +XXX,XX @@ static const struct omap_partition_info_s { |
48 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 40 | { 0x00080000, 0x00200000, 0x0, "kernel" }, |
49 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | 41 | { 0x00280000, 0x00200000, 0x3, "initfs" }, |
50 | new file mode 100644 | 42 | { 0x00480000, 0x0fb80000, 0x3, "rootfs" }, |
51 | index XXXXXXX..XXXXXXX | ||
52 | --- /dev/null | ||
53 | +++ b/target/arm/vec_internal.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | +/* | ||
56 | + * ARM AdvSIMD / SVE Vector Helpers | ||
57 | + * | ||
58 | + * Copyright (c) 2020 Linaro | ||
59 | + * | ||
60 | + * This library is free software; you can redistribute it and/or | ||
61 | + * modify it under the terms of the GNU Lesser General Public | ||
62 | + * License as published by the Free Software Foundation; either | ||
63 | + * version 2 of the License, or (at your option) any later version. | ||
64 | + * | ||
65 | + * This library is distributed in the hope that it will be useful, | ||
66 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
67 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
68 | + * Lesser General Public License for more details. | ||
69 | + * | ||
70 | + * You should have received a copy of the GNU Lesser General Public | ||
71 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
72 | + */ | ||
73 | + | ||
74 | +#ifndef TARGET_ARM_VEC_INTERNALS_H | ||
75 | +#define TARGET_ARM_VEC_INTERNALS_H | ||
76 | + | ||
77 | +static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | ||
78 | +{ | ||
79 | + uint64_t *d = vd + opr_sz; | ||
80 | + uintptr_t i; | ||
81 | + | ||
82 | + for (i = opr_sz; i < max_sz; i += 8) { | ||
83 | + *d++ = 0; | ||
84 | + } | ||
85 | +} | ||
86 | + | ||
87 | +#endif /* TARGET_ARM_VEC_INTERNALS_H */ | ||
88 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/crypto_helper.c | ||
91 | +++ b/target/arm/crypto_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ | ||
93 | |||
94 | #include "cpu.h" | ||
95 | #include "exec/helper-proto.h" | ||
96 | +#include "tcg/tcg-gvec-desc.h" | ||
97 | #include "crypto/aes.h" | ||
98 | +#include "vec_internal.h" | ||
99 | |||
100 | union CRYPTO_STATE { | ||
101 | uint8_t bytes[16]; | ||
102 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | ||
103 | #define CR_ST_WORD(state, i) (state.words[i]) | ||
104 | #endif | ||
105 | |||
106 | -void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | ||
107 | +static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | ||
108 | + uint64_t *rm, bool decrypt) | ||
109 | { | ||
110 | static uint8_t const * const sbox[2] = { AES_sbox, AES_isbox }; | ||
111 | static uint8_t const * const shift[2] = { AES_shifts, AES_ishifts }; | ||
112 | - uint64_t *rd = vd; | ||
113 | - uint64_t *rm = vm; | ||
114 | union CRYPTO_STATE rk = { .l = { rm[0], rm[1] } }; | ||
115 | - union CRYPTO_STATE st = { .l = { rd[0], rd[1] } }; | ||
116 | + union CRYPTO_STATE st = { .l = { rn[0], rn[1] } }; | ||
117 | int i; | ||
118 | |||
119 | - assert(decrypt < 2); | ||
120 | - | 43 | - |
121 | /* xor state vector with round key */ | 44 | - { 0, 0, 0, NULL } |
122 | rk.l[0] ^= st.l[0]; | 45 | + { /* end of list */ } |
123 | rk.l[1] ^= st.l[1]; | 46 | }, n810_part_info[] = { |
124 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | 47 | { 0x00000000, 0x00020000, 0x3, "bootloader" }, |
125 | rd[1] = st.l[1]; | 48 | { 0x00020000, 0x00060000, 0x0, "config" }, |
126 | } | 49 | { 0x00080000, 0x00220000, 0x0, "kernel" }, |
127 | 50 | { 0x002a0000, 0x00400000, 0x0, "initfs" }, | |
128 | -void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | 51 | { 0x006a0000, 0x0f960000, 0x0, "rootfs" }, |
129 | +void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) | ||
130 | +{ | ||
131 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
132 | + bool decrypt = simd_data(desc); | ||
133 | + | ||
134 | + for (i = 0; i < opr_sz; i += 16) { | ||
135 | + do_crypto_aese(vd + i, vn + i, vm + i, decrypt); | ||
136 | + } | ||
137 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
138 | +} | ||
139 | + | ||
140 | +static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, bool decrypt) | ||
141 | { | ||
142 | static uint32_t const mc[][256] = { { | ||
143 | /* MixColumns lookup table */ | ||
144 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
145 | 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, | ||
146 | } }; | ||
147 | |||
148 | - uint64_t *rd = vd; | ||
149 | - uint64_t *rm = vm; | ||
150 | union CRYPTO_STATE st = { .l = { rm[0], rm[1] } }; | ||
151 | int i; | ||
152 | |||
153 | - assert(decrypt < 2); | ||
154 | - | 52 | - |
155 | for (i = 0; i < 16; i += 4) { | 53 | - { 0, 0, 0, NULL } |
156 | CR_ST_WORD(st, i >> 2) = | 54 | + { /* end of list */ } |
157 | mc[decrypt][CR_ST_BYTE(st, i)] ^ | ||
158 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
159 | rd[1] = st.l[1]; | ||
160 | } | ||
161 | |||
162 | +void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) | ||
163 | +{ | ||
164 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
165 | + bool decrypt = simd_data(desc); | ||
166 | + | ||
167 | + for (i = 0; i < opr_sz; i += 16) { | ||
168 | + do_crypto_aesmc(vd + i, vm + i, decrypt); | ||
169 | + } | ||
170 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
171 | +} | ||
172 | + | ||
173 | /* | ||
174 | * SHA-1 logical functions | ||
175 | */ | ||
176 | @@ -XXX,XX +XXX,XX @@ static uint8_t const sm4_sbox[] = { | ||
177 | 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48, | ||
178 | }; | 55 | }; |
179 | 56 | ||
180 | -void HELPER(crypto_sm4e)(void *vd, void *vn) | 57 | static const uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR }; |
181 | +static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn, uint64_t *rm) | ||
182 | { | ||
183 | - uint64_t *rd = vd; | ||
184 | - uint64_t *rn = vn; | ||
185 | - union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
186 | - union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
187 | + union CRYPTO_STATE d = { .l = { rn[0], rn[1] } }; | ||
188 | + union CRYPTO_STATE n = { .l = { rm[0], rm[1] } }; | ||
189 | uint32_t t, i; | ||
190 | |||
191 | for (i = 0; i < 4; i++) { | ||
192 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4e)(void *vd, void *vn) | ||
193 | rd[1] = d.l[1]; | ||
194 | } | ||
195 | |||
196 | -void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | ||
197 | +void HELPER(crypto_sm4e)(void *vd, void *vn, void *vm, uint32_t desc) | ||
198 | +{ | ||
199 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
200 | + | ||
201 | + for (i = 0; i < opr_sz; i += 16) { | ||
202 | + do_crypto_sm4e(vd + i, vn + i, vm + i); | ||
203 | + } | ||
204 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
205 | +} | ||
206 | + | ||
207 | +static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *rn, uint64_t *rm) | ||
208 | { | ||
209 | - uint64_t *rd = vd; | ||
210 | - uint64_t *rn = vn; | ||
211 | - uint64_t *rm = vm; | ||
212 | union CRYPTO_STATE d; | ||
213 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
214 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
215 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | ||
216 | rd[0] = d.l[0]; | ||
217 | rd[1] = d.l[1]; | ||
218 | } | ||
219 | + | ||
220 | +void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm, uint32_t desc) | ||
221 | +{ | ||
222 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
223 | + | ||
224 | + for (i = 0; i < opr_sz; i += 16) { | ||
225 | + do_crypto_sm4ekey(vd + i, vn + i, vm + i); | ||
226 | + } | ||
227 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
228 | +} | ||
229 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
230 | index XXXXXXX..XXXXXXX 100644 | ||
231 | --- a/target/arm/translate-a64.c | ||
232 | +++ b/target/arm/translate-a64.c | ||
233 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn4(DisasContext *s, bool is_q, int rd, int rn, int rm, | ||
234 | is_q ? 16 : 8, vec_full_reg_size(s)); | ||
235 | } | ||
236 | |||
237 | +/* Expand a 2-operand operation using an out-of-line helper. */ | ||
238 | +static void gen_gvec_op2_ool(DisasContext *s, bool is_q, int rd, | ||
239 | + int rn, int data, gen_helper_gvec_2 *fn) | ||
240 | +{ | ||
241 | + tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | ||
242 | + vec_full_reg_offset(s, rn), | ||
243 | + is_q ? 16 : 8, vec_full_reg_size(s), data, fn); | ||
244 | +} | ||
245 | + | ||
246 | /* Expand a 3-operand operation using an out-of-line helper. */ | ||
247 | static void gen_gvec_op3_ool(DisasContext *s, bool is_q, int rd, | ||
248 | int rn, int rm, int data, gen_helper_gvec_3 *fn) | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
250 | int rn = extract32(insn, 5, 5); | ||
251 | int rd = extract32(insn, 0, 5); | ||
252 | int decrypt; | ||
253 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
254 | - TCGv_i32 tcg_decrypt; | ||
255 | - CryptoThreeOpIntFn *genfn; | ||
256 | + gen_helper_gvec_2 *genfn2 = NULL; | ||
257 | + gen_helper_gvec_3 *genfn3 = NULL; | ||
258 | |||
259 | if (!dc_isar_feature(aa64_aes, s) || size != 0) { | ||
260 | unallocated_encoding(s); | ||
261 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
262 | switch (opcode) { | ||
263 | case 0x4: /* AESE */ | ||
264 | decrypt = 0; | ||
265 | - genfn = gen_helper_crypto_aese; | ||
266 | + genfn3 = gen_helper_crypto_aese; | ||
267 | break; | ||
268 | case 0x6: /* AESMC */ | ||
269 | decrypt = 0; | ||
270 | - genfn = gen_helper_crypto_aesmc; | ||
271 | + genfn2 = gen_helper_crypto_aesmc; | ||
272 | break; | ||
273 | case 0x5: /* AESD */ | ||
274 | decrypt = 1; | ||
275 | - genfn = gen_helper_crypto_aese; | ||
276 | + genfn3 = gen_helper_crypto_aese; | ||
277 | break; | ||
278 | case 0x7: /* AESIMC */ | ||
279 | decrypt = 1; | ||
280 | - genfn = gen_helper_crypto_aesmc; | ||
281 | + genfn2 = gen_helper_crypto_aesmc; | ||
282 | break; | ||
283 | default: | ||
284 | unallocated_encoding(s); | ||
285 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
286 | if (!fp_access_check(s)) { | ||
287 | return; | ||
288 | } | ||
289 | - | ||
290 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
291 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
292 | - tcg_decrypt = tcg_const_i32(decrypt); | ||
293 | - | ||
294 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_decrypt); | ||
295 | - | ||
296 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
297 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
298 | - tcg_temp_free_i32(tcg_decrypt); | ||
299 | + if (genfn2) { | ||
300 | + gen_gvec_op2_ool(s, true, rd, rn, decrypt, genfn2); | ||
301 | + } else { | ||
302 | + gen_gvec_op3_ool(s, true, rd, rd, rn, decrypt, genfn3); | ||
303 | + } | ||
304 | } | ||
305 | |||
306 | /* Crypto three-reg SHA | ||
307 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
308 | int rn = extract32(insn, 5, 5); | ||
309 | int rd = extract32(insn, 0, 5); | ||
310 | bool feature; | ||
311 | - CryptoThreeOpFn *genfn; | ||
312 | + CryptoThreeOpFn *genfn = NULL; | ||
313 | + gen_helper_gvec_3 *oolfn = NULL; | ||
314 | |||
315 | if (o == 0) { | ||
316 | switch (opcode) { | ||
317 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
318 | break; | ||
319 | case 2: /* SM4EKEY */ | ||
320 | feature = dc_isar_feature(aa64_sm4, s); | ||
321 | - genfn = gen_helper_crypto_sm4ekey; | ||
322 | + oolfn = gen_helper_crypto_sm4ekey; | ||
323 | break; | ||
324 | default: | ||
325 | unallocated_encoding(s); | ||
326 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
327 | return; | ||
328 | } | ||
329 | |||
330 | + if (oolfn) { | ||
331 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
332 | + return; | ||
333 | + } | ||
334 | + | ||
335 | if (genfn) { | ||
336 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
337 | |||
338 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
339 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
340 | bool feature; | ||
341 | CryptoTwoOpFn *genfn; | ||
342 | + gen_helper_gvec_3 *oolfn = NULL; | ||
343 | |||
344 | switch (opcode) { | ||
345 | case 0: /* SHA512SU0 */ | ||
346 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
347 | break; | ||
348 | case 1: /* SM4E */ | ||
349 | feature = dc_isar_feature(aa64_sm4, s); | ||
350 | - genfn = gen_helper_crypto_sm4e; | ||
351 | + oolfn = gen_helper_crypto_sm4e; | ||
352 | break; | ||
353 | default: | ||
354 | unallocated_encoding(s); | ||
355 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
356 | return; | ||
357 | } | ||
358 | |||
359 | + if (oolfn) { | ||
360 | + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, oolfn); | ||
361 | + return; | ||
362 | + } | ||
363 | + | ||
364 | tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
365 | tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
366 | |||
367 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
368 | index XXXXXXX..XXXXXXX 100644 | ||
369 | --- a/target/arm/translate.c | ||
370 | +++ b/target/arm/translate.c | ||
371 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
372 | if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | ||
373 | return 1; | ||
374 | } | ||
375 | - ptr1 = vfp_reg_ptr(true, rd); | ||
376 | - ptr2 = vfp_reg_ptr(true, rm); | ||
377 | - | ||
378 | - /* Bit 6 is the lowest opcode bit; it distinguishes between | ||
379 | - * encryption (AESE/AESMC) and decryption (AESD/AESIMC) | ||
380 | - */ | ||
381 | - tmp3 = tcg_const_i32(extract32(insn, 6, 1)); | ||
382 | - | ||
383 | + /* | ||
384 | + * Bit 6 is the lowest opcode bit; it distinguishes | ||
385 | + * between encryption (AESE/AESMC) and decryption | ||
386 | + * (AESD/AESIMC). | ||
387 | + */ | ||
388 | if (op == NEON_2RM_AESE) { | ||
389 | - gen_helper_crypto_aese(ptr1, ptr2, tmp3); | ||
390 | + tcg_gen_gvec_3_ool(vfp_reg_offset(true, rd), | ||
391 | + vfp_reg_offset(true, rd), | ||
392 | + vfp_reg_offset(true, rm), | ||
393 | + 16, 16, extract32(insn, 6, 1), | ||
394 | + gen_helper_crypto_aese); | ||
395 | } else { | ||
396 | - gen_helper_crypto_aesmc(ptr1, ptr2, tmp3); | ||
397 | + tcg_gen_gvec_2_ool(vfp_reg_offset(true, rd), | ||
398 | + vfp_reg_offset(true, rm), | ||
399 | + 16, 16, extract32(insn, 6, 1), | ||
400 | + gen_helper_crypto_aesmc); | ||
401 | } | ||
402 | - tcg_temp_free_ptr(ptr1); | ||
403 | - tcg_temp_free_ptr(ptr2); | ||
404 | - tcg_temp_free_i32(tmp3); | ||
405 | break; | ||
406 | case NEON_2RM_SHA1H: | ||
407 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
408 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
409 | index XXXXXXX..XXXXXXX 100644 | ||
410 | --- a/target/arm/vec_helper.c | ||
411 | +++ b/target/arm/vec_helper.c | ||
412 | @@ -XXX,XX +XXX,XX @@ | ||
413 | #include "exec/helper-proto.h" | ||
414 | #include "tcg/tcg-gvec-desc.h" | ||
415 | #include "fpu/softfloat.h" | ||
416 | - | ||
417 | +#include "vec_internal.h" | ||
418 | |||
419 | /* Note that vector data is stored in host-endian 64-bit chunks, | ||
420 | so addressing units smaller than that needs a host-endian fixup. */ | ||
421 | @@ -XXX,XX +XXX,XX @@ | ||
422 | #define H4(x) (x) | ||
423 | #endif | ||
424 | |||
425 | -static void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | ||
426 | -{ | ||
427 | - uint64_t *d = vd + opr_sz; | ||
428 | - uintptr_t i; | ||
429 | - | ||
430 | - for (i = opr_sz; i < max_sz; i += 8) { | ||
431 | - *d++ = 0; | ||
432 | - } | ||
433 | -} | ||
434 | - | ||
435 | /* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */ | ||
436 | static int16_t inl_qrdmlah_s16(int16_t src1, int16_t src2, | ||
437 | int16_t src3, uint32_t *sat) | ||
438 | -- | 58 | -- |
439 | 2.20.1 | 59 | 2.25.1 |
440 | 60 | ||
441 | 61 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Zhuojia Shen <chaosdefinition@hotmail.com> | |
2 | |||
3 | In CPUID registers exposed to userspace, some registers were missing | ||
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] | ||
62 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
63 | --- | ||
64 | target/arm/helper.c | 96 +++++++++++++++++++++++++------ | ||
65 | tests/tcg/aarch64/sysregs.c | 24 ++++++-- | ||
66 | tests/tcg/aarch64/Makefile.target | 7 ++- | ||
67 | 3 files changed, 103 insertions(+), 24 deletions(-) | ||
68 | |||
69 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/helper.c | ||
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 | ||
197 | @@ -XXX,XX +XXX,XX @@ | ||
198 | #define HWCAP_CPUID (1 << 11) | ||
199 | #endif | ||
200 | |||
201 | +/* | ||
202 | + * Older assemblers don't recognize newer system register names, | ||
203 | + * but we can still access them by the Sn_n_Cn_Cn_n syntax. | ||
204 | + */ | ||
205 | +#define SYS_ID_AA64ISAR2_EL1 S3_0_C0_C6_2 | ||
206 | +#define SYS_ID_AA64MMFR2_EL1 S3_0_C0_C7_2 | ||
207 | + | ||
208 | int failed_bit_count; | ||
209 | |||
210 | /* Read and print system register `id' value */ | ||
211 | @@ -XXX,XX +XXX,XX @@ int main(void) | ||
212 | * minimum valid fields - for the purposes of this check allowed | ||
213 | * to have non-zero values. | ||
214 | */ | ||
215 | - get_cpu_reg_check_mask(id_aa64isar0_el1, _m(00ff,ffff,f0ff,fff0)); | ||
216 | - get_cpu_reg_check_mask(id_aa64isar1_el1, _m(0000,00f0,ffff,ffff)); | ||
217 | + get_cpu_reg_check_mask(id_aa64isar0_el1, _m(f0ff,ffff,f0ff,fff0)); | ||
218 | + get_cpu_reg_check_mask(id_aa64isar1_el1, _m(00ff,f0ff,ffff,ffff)); | ||
219 | + get_cpu_reg_check_mask(SYS_ID_AA64ISAR2_EL1, _m(0000,0000,0000,ffff)); | ||
220 | /* TGran4 & TGran64 as pegged to -1 */ | ||
221 | - get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(0000,0000,ff00,0000)); | ||
222 | - get_cpu_reg_check_zero(id_aa64mmfr1_el1); | ||
223 | + get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(f000,0000,ff00,0000)); | ||
224 | + get_cpu_reg_check_mask(id_aa64mmfr1_el1, _m(0000,f000,0000,0000)); | ||
225 | + get_cpu_reg_check_mask(SYS_ID_AA64MMFR2_EL1, _m(0000,000f,0000,0000)); | ||
226 | /* EL1/EL0 reported as AA64 only */ | ||
227 | get_cpu_reg_check_mask(id_aa64pfr0_el1, _m(000f,000f,00ff,0011)); | ||
228 | - get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0000,00f0)); | ||
229 | + get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0f00,0fff)); | ||
230 | /* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */ | ||
231 | get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006)); | ||
232 | get_cpu_reg_check_zero(id_aa64dfr1_el1); | ||
233 | - get_cpu_reg_check_zero(id_aa64zfr0_el1); | ||
234 | + get_cpu_reg_check_mask(id_aa64zfr0_el1, _m(0ff0,ff0f,00ff,00ff)); | ||
235 | +#ifdef HAS_ARMV9_SME | ||
236 | + get_cpu_reg_check_mask(id_aa64smfr0_el1, _m(80f1,00fd,0000,0000)); | ||
237 | +#endif | ||
238 | |||
239 | get_cpu_reg_check_zero(id_aa64afr0_el1); | ||
240 | get_cpu_reg_check_zero(id_aa64afr1_el1); | ||
241 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
242 | index XXXXXXX..XXXXXXX 100644 | ||
243 | --- a/tests/tcg/aarch64/Makefile.target | ||
244 | +++ b/tests/tcg/aarch64/Makefile.target | ||
245 | @@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile | ||
246 | $(call cc-option,-march=armv8.1-a+sve2, CROSS_CC_HAS_SVE2); \ | ||
247 | $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \ | ||
248 | $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \ | ||
249 | - $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE)) 3> config-cc.mak | ||
250 | + $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \ | ||
251 | + $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak | ||
252 | -include config-cc.mak | ||
253 | |||
254 | # Pauth Tests | ||
255 | @@ -XXX,XX +XXX,XX @@ endif | ||
256 | ifneq ($(CROSS_CC_HAS_SVE),) | ||
257 | # System Registers Tests | ||
258 | AARCH64_TESTS += sysregs | ||
259 | +ifneq ($(CROSS_CC_HAS_ARMV9_SME),) | ||
260 | +sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME | ||
261 | +else | ||
262 | sysregs: CFLAGS+=-march=armv8.1-a+sve | ||
263 | +endif | ||
264 | |||
265 | # SVE ioctl test | ||
266 | AARCH64_TESTS += sve-ioctls | ||
267 | -- | ||
268 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Wire the dwc-hsotg (dwc2) emulation into Qemu | 3 | This function is not used anywhere outside this file, |
4 | so we can make the function "static void". | ||
4 | 5 | ||
5 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200520235349.21215-7-pauldzim@gmail.com | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
9 | Message-id: 20221216214924.4711-2-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | include/hw/arm/bcm2835_peripherals.h | 3 ++- | 12 | include/hw/arm/smmu-common.h | 3 --- |
11 | hw/arm/bcm2835_peripherals.c | 21 ++++++++++++++++++++- | 13 | hw/arm/smmu-common.c | 2 +- |
12 | 2 files changed, 22 insertions(+), 2 deletions(-) | 14 | 2 files changed, 1 insertion(+), 4 deletions(-) |
13 | 15 | ||
14 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 16 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/bcm2835_peripherals.h | 18 | --- a/include/hw/arm/smmu-common.h |
17 | +++ b/include/hw/arm/bcm2835_peripherals.h | 19 | +++ b/include/hw/arm/smmu-common.h |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, |
19 | #include "hw/sd/bcm2835_sdhost.h" | 21 | /* Unmap the range of all the notifiers registered to any IOMMU mr */ |
20 | #include "hw/gpio/bcm2835_gpio.h" | 22 | void smmu_inv_notifiers_all(SMMUState *s); |
21 | #include "hw/timer/bcm2835_systmr.h" | 23 | |
22 | +#include "hw/usb/hcd-dwc2.h" | 24 | -/* Unmap the range of all the notifiers registered to @mr */ |
23 | #include "hw/misc/unimp.h" | 25 | -void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr); |
24 | 26 | - | |
25 | #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" | 27 | #endif /* HW_ARM_SMMU_COMMON_H */ |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | 28 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
27 | UnimplementedDeviceState ave0; | ||
28 | UnimplementedDeviceState bscsl; | ||
29 | UnimplementedDeviceState smi; | ||
30 | - UnimplementedDeviceState dwc2; | ||
31 | + DWC2State dwc2; | ||
32 | UnimplementedDeviceState sdramc; | ||
33 | } BCM2835PeripheralState; | ||
34 | |||
35 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/arm/bcm2835_peripherals.c | 30 | --- a/hw/arm/smmu-common.c |
38 | +++ b/hw/arm/bcm2835_peripherals.c | 31 | +++ b/hw/arm/smmu-common.c |
39 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 32 | @@ -XXX,XX +XXX,XX @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n) |
40 | /* Mphi */ | ||
41 | sysbus_init_child_obj(obj, "mphi", &s->mphi, sizeof(s->mphi), | ||
42 | TYPE_BCM2835_MPHI); | ||
43 | + | ||
44 | + /* DWC2 */ | ||
45 | + sysbus_init_child_obj(obj, "dwc2", &s->dwc2, sizeof(s->dwc2), | ||
46 | + TYPE_DWC2_USB); | ||
47 | + | ||
48 | + object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | ||
49 | + OBJECT(&s->gpu_bus_mr)); | ||
50 | } | 33 | } |
51 | 34 | ||
52 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 35 | /* Unmap all notifiers attached to @mr */ |
53 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 36 | -inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) |
54 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 37 | +static void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) |
55 | INTERRUPT_HOSTPORT)); | 38 | { |
56 | 39 | IOMMUNotifier *n; | |
57 | + /* DWC2 */ | ||
58 | + object_property_set_bool(OBJECT(&s->dwc2), true, "realized", &err); | ||
59 | + if (err) { | ||
60 | + error_propagate(errp, err); | ||
61 | + return; | ||
62 | + } | ||
63 | + | ||
64 | + memory_region_add_subregion(&s->peri_mr, USB_OTG_OFFSET, | ||
65 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dwc2), 0)); | ||
66 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->dwc2), 0, | ||
67 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
68 | + INTERRUPT_USB)); | ||
69 | + | ||
70 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
71 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
72 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
74 | create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); | ||
75 | create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); | ||
76 | create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); | ||
77 | - create_unimp(s, &s->dwc2, "dwc-usb2", USB_OTG_OFFSET, 0x1000); | ||
78 | create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100); | ||
79 | } | ||
80 | 40 | ||
81 | -- | 41 | -- |
82 | 2.20.1 | 42 | 2.25.1 |
83 | 43 | ||
84 | 44 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | When using Clang ("Apple clang version 14.0.0 (clang-1400.0.29.202)") |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | and building with -Wall we get: |
5 | an existing bug vs SVE. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 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] |
8 | Message-id: 20200514212831.31248-5-richard.henderson@linaro.org | 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 | ||
11 | |||
12 | None of our code base require / use inlined functions with external | ||
13 | linkage. Some places use internal inlining in the hot path. These | ||
14 | two functions are certainly not in any hot path and don't justify | ||
15 | any inlining, so these are likely oversights rather than intentional. | ||
16 | |||
17 | Reported-by: Stefan Weil <sw@weilnetz.de> | ||
9 | 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 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 24 | --- |
12 | target/arm/helper.h | 12 ++-- | 25 | hw/arm/smmu-common.c | 13 ++++++------- |
13 | target/arm/neon-dp.decode | 12 ++-- | 26 | 1 file changed, 6 insertions(+), 7 deletions(-) |
14 | target/arm/crypto_helper.c | 24 +++++-- | ||
15 | target/arm/translate-a64.c | 34 ++++----- | ||
16 | target/arm/translate-neon.inc.c | 124 +++++--------------------------- | ||
17 | target/arm/translate.c | 24 ++----- | ||
18 | 6 files changed, 67 insertions(+), 163 deletions(-) | ||
19 | 27 | ||
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 28 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
21 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.h | 30 | --- a/hw/arm/smmu-common.c |
23 | +++ b/target/arm/helper.h | 31 | +++ b/hw/arm/smmu-common.c |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 32 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *new) |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 33 | g_hash_table_insert(bs->iotlb, key, new); |
26 | |||
27 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | -DEF_HELPER_FLAGS_2(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
29 | -DEF_HELPER_FLAGS_2(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
32 | |||
33 | -DEF_HELPER_FLAGS_3(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
34 | -DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
35 | -DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
36 | -DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
37 | +DEF_HELPER_FLAGS_4(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_3(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
41 | |||
42 | DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
43 | DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
44 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/neon-dp.decode | ||
47 | +++ b/target/arm/neon-dp.decode | ||
48 | @@ -XXX,XX +XXX,XX @@ VPADD_3s 1111 001 0 0 . .. .... .... 1011 . . . 1 .... @3same_q0 | ||
49 | |||
50 | VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | ||
51 | |||
52 | +@3same_crypto .... .... .... .... .... .... .... .... \ | ||
53 | + &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | ||
54 | + | ||
55 | SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | ||
56 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
57 | -SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... \ | ||
58 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
59 | -SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... \ | ||
60 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
61 | -SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... \ | ||
62 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
63 | +SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
64 | +SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
65 | +SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
66 | |||
67 | VFMA_fp_3s 1111 001 0 0 . 0 . .... .... 1100 ... 1 .... @3same_fp | ||
68 | VFMS_fp_3s 1111 001 0 0 . 1 . .... .... 1100 ... 1 .... @3same_fp | ||
69 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/crypto_helper.c | ||
72 | +++ b/target/arm/crypto_helper.c | ||
73 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | ||
74 | rd[1] = d.l[1]; | ||
75 | } | 34 | } |
76 | 35 | ||
77 | -void HELPER(crypto_sha1h)(void *vd, void *vm) | 36 | -inline void smmu_iotlb_inv_all(SMMUState *s) |
78 | +void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | 37 | +void smmu_iotlb_inv_all(SMMUState *s) |
79 | { | 38 | { |
80 | uint64_t *rd = vd; | 39 | trace_smmu_iotlb_inv_all(); |
81 | uint64_t *rm = vm; | 40 | g_hash_table_remove_all(s->iotlb); |
82 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1h)(void *vd, void *vm) | 41 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value, |
83 | 42 | ((entry->iova & ~info->mask) == info->iova); | |
84 | rd[0] = m.l[0]; | ||
85 | rd[1] = m.l[1]; | ||
86 | + | ||
87 | + clear_tail_16(vd, desc); | ||
88 | } | 43 | } |
89 | 44 | ||
90 | -void HELPER(crypto_sha1su1)(void *vd, void *vm) | 45 | -inline void |
91 | +void HELPER(crypto_sha1su1)(void *vd, void *vm, uint32_t desc) | 46 | -smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, |
47 | - uint8_t tg, uint64_t num_pages, uint8_t ttl) | ||
48 | +void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
49 | + uint8_t tg, uint64_t num_pages, uint8_t ttl) | ||
92 | { | 50 | { |
93 | uint64_t *rd = vd; | 51 | /* if tg is not set we use 4KB range invalidation */ |
94 | uint64_t *rm = vm; | 52 | uint8_t granule = tg ? tg * 2 + 10 : 12; |
95 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1su1)(void *vd, void *vm) | 53 | @@ -XXX,XX +XXX,XX @@ smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, |
96 | 54 | &info); | |
97 | rd[0] = d.l[0]; | ||
98 | rd[1] = d.l[1]; | ||
99 | + | ||
100 | + clear_tail_16(vd, desc); | ||
101 | } | 55 | } |
102 | 56 | ||
103 | /* | 57 | -inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) |
104 | @@ -XXX,XX +XXX,XX @@ static uint32_t s1(uint32_t x) | 58 | +void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) |
105 | return ror32(x, 17) ^ ror32(x, 19) ^ (x >> 10); | ||
106 | } | ||
107 | |||
108 | -void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | ||
109 | +void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
110 | { | 59 | { |
111 | uint64_t *rd = vd; | 60 | trace_smmu_iotlb_inv_asid(asid); |
112 | uint64_t *rn = vn; | 61 | g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid); |
113 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | 62 | @@ -XXX,XX +XXX,XX @@ error: |
114 | 63 | * | |
115 | rd[0] = d.l[0]; | 64 | * return 0 on success |
116 | rd[1] = d.l[1]; | 65 | */ |
117 | + | 66 | -inline int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, |
118 | + clear_tail_16(vd, desc); | 67 | - SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) |
119 | } | 68 | +int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, |
120 | 69 | + SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | |
121 | -void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | ||
122 | +void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
123 | { | 70 | { |
124 | uint64_t *rd = vd; | 71 | if (!cfg->aa64) { |
125 | uint64_t *rn = vn; | 72 | /* |
126 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | ||
127 | |||
128 | rd[0] = d.l[0]; | ||
129 | rd[1] = d.l[1]; | ||
130 | + | ||
131 | + clear_tail_16(vd, desc); | ||
132 | } | ||
133 | |||
134 | -void HELPER(crypto_sha256su0)(void *vd, void *vm) | ||
135 | +void HELPER(crypto_sha256su0)(void *vd, void *vm, uint32_t desc) | ||
136 | { | ||
137 | uint64_t *rd = vd; | ||
138 | uint64_t *rm = vm; | ||
139 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su0)(void *vd, void *vm) | ||
140 | |||
141 | rd[0] = d.l[0]; | ||
142 | rd[1] = d.l[1]; | ||
143 | + | ||
144 | + clear_tail_16(vd, desc); | ||
145 | } | ||
146 | |||
147 | -void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | ||
148 | +void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
149 | { | ||
150 | uint64_t *rd = vd; | ||
151 | uint64_t *rn = vn; | ||
152 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | ||
153 | |||
154 | rd[0] = d.l[0]; | ||
155 | rd[1] = d.l[1]; | ||
156 | + | ||
157 | + clear_tail_16(vd, desc); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/target/arm/translate-a64.c | ||
164 | +++ b/target/arm/translate-a64.c | ||
165 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
166 | int rm = extract32(insn, 16, 5); | ||
167 | int rn = extract32(insn, 5, 5); | ||
168 | int rd = extract32(insn, 0, 5); | ||
169 | - CryptoThreeOpFn *genfn; | ||
170 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
171 | + gen_helper_gvec_3 *genfn; | ||
172 | bool feature; | ||
173 | |||
174 | if (size != 0) { | ||
175 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
180 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
181 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
182 | - | ||
183 | if (genfn) { | ||
184 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | ||
185 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
186 | } else { | ||
187 | TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | ||
188 | + TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
189 | + TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
190 | + TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
191 | |||
192 | gen_helper_crypto_sha1_3reg(tcg_rd_ptr, tcg_rn_ptr, | ||
193 | tcg_rm_ptr, tcg_opcode); | ||
194 | - tcg_temp_free_i32(tcg_opcode); | ||
195 | - } | ||
196 | |||
197 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
198 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
199 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
200 | + tcg_temp_free_i32(tcg_opcode); | ||
201 | + tcg_temp_free_ptr(tcg_rd_ptr); | ||
202 | + tcg_temp_free_ptr(tcg_rn_ptr); | ||
203 | + tcg_temp_free_ptr(tcg_rm_ptr); | ||
204 | + } | ||
205 | } | ||
206 | |||
207 | /* Crypto two-reg SHA | ||
208 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
209 | int opcode = extract32(insn, 12, 5); | ||
210 | int rn = extract32(insn, 5, 5); | ||
211 | int rd = extract32(insn, 0, 5); | ||
212 | - CryptoTwoOpFn *genfn; | ||
213 | + gen_helper_gvec_2 *genfn; | ||
214 | bool feature; | ||
215 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
216 | |||
217 | if (size != 0) { | ||
218 | unallocated_encoding(s); | ||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
220 | if (!fp_access_check(s)) { | ||
221 | return; | ||
222 | } | ||
223 | - | ||
224 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
225 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
226 | - | ||
227 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | ||
228 | - | ||
229 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
230 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
231 | + gen_gvec_op2_ool(s, true, rd, rn, 0, genfn); | ||
232 | } | ||
233 | |||
234 | static void gen_rax1_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) | ||
235 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/target/arm/translate-neon.inc.c | ||
238 | +++ b/target/arm/translate-neon.inc.c | ||
239 | @@ -XXX,XX +XXX,XX @@ DO_3SAME_CMP(VCGE_S, TCG_COND_GE) | ||
240 | DO_3SAME_CMP(VCGE_U, TCG_COND_GEU) | ||
241 | DO_3SAME_CMP(VCEQ, TCG_COND_EQ) | ||
242 | |||
243 | -static void gen_VMUL_p_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
244 | - uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) | ||
245 | -{ | ||
246 | - tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, | ||
247 | - 0, gen_helper_gvec_pmul_b); | ||
248 | -} | ||
249 | +#define WRAP_OOL_FN(WRAPNAME, FUNC) \ | ||
250 | + static void WRAPNAME(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, \ | ||
251 | + uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) \ | ||
252 | + { \ | ||
253 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, 0, FUNC); \ | ||
254 | + } | ||
255 | + | ||
256 | +WRAP_OOL_FN(gen_VMUL_p_3s, gen_helper_gvec_pmul_b) | ||
257 | |||
258 | static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | ||
259 | { | ||
260 | @@ -XXX,XX +XXX,XX @@ static bool trans_SHA1_3s(DisasContext *s, arg_SHA1_3s *a) | ||
261 | return true; | ||
262 | } | ||
263 | |||
264 | -static bool trans_SHA256H_3s(DisasContext *s, arg_SHA256H_3s *a) | ||
265 | -{ | ||
266 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
267 | - | ||
268 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
269 | - !dc_isar_feature(aa32_sha2, s)) { | ||
270 | - return false; | ||
271 | +#define DO_SHA2(NAME, FUNC) \ | ||
272 | + WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
273 | + static bool trans_##NAME##_3s(DisasContext *s, arg_3same *a) \ | ||
274 | + { \ | ||
275 | + if (!dc_isar_feature(aa32_sha2, s)) { \ | ||
276 | + return false; \ | ||
277 | + } \ | ||
278 | + return do_3same(s, a, gen_##NAME##_3s); \ | ||
279 | } | ||
280 | |||
281 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
282 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
283 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
284 | - return false; | ||
285 | - } | ||
286 | - | ||
287 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
288 | - return false; | ||
289 | - } | ||
290 | - | ||
291 | - if (!vfp_access_check(s)) { | ||
292 | - return true; | ||
293 | - } | ||
294 | - | ||
295 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
296 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
297 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
298 | - gen_helper_crypto_sha256h(ptr1, ptr2, ptr3); | ||
299 | - tcg_temp_free_ptr(ptr1); | ||
300 | - tcg_temp_free_ptr(ptr2); | ||
301 | - tcg_temp_free_ptr(ptr3); | ||
302 | - | ||
303 | - return true; | ||
304 | -} | ||
305 | - | ||
306 | -static bool trans_SHA256H2_3s(DisasContext *s, arg_SHA256H2_3s *a) | ||
307 | -{ | ||
308 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
309 | - | ||
310 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
311 | - !dc_isar_feature(aa32_sha2, s)) { | ||
312 | - return false; | ||
313 | - } | ||
314 | - | ||
315 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
316 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
317 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
318 | - return false; | ||
319 | - } | ||
320 | - | ||
321 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
322 | - return false; | ||
323 | - } | ||
324 | - | ||
325 | - if (!vfp_access_check(s)) { | ||
326 | - return true; | ||
327 | - } | ||
328 | - | ||
329 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
330 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
331 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
332 | - gen_helper_crypto_sha256h2(ptr1, ptr2, ptr3); | ||
333 | - tcg_temp_free_ptr(ptr1); | ||
334 | - tcg_temp_free_ptr(ptr2); | ||
335 | - tcg_temp_free_ptr(ptr3); | ||
336 | - | ||
337 | - return true; | ||
338 | -} | ||
339 | - | ||
340 | -static bool trans_SHA256SU1_3s(DisasContext *s, arg_SHA256SU1_3s *a) | ||
341 | -{ | ||
342 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
343 | - | ||
344 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
345 | - !dc_isar_feature(aa32_sha2, s)) { | ||
346 | - return false; | ||
347 | - } | ||
348 | - | ||
349 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
350 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
351 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
352 | - return false; | ||
353 | - } | ||
354 | - | ||
355 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
356 | - return false; | ||
357 | - } | ||
358 | - | ||
359 | - if (!vfp_access_check(s)) { | ||
360 | - return true; | ||
361 | - } | ||
362 | - | ||
363 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
364 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
365 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
366 | - gen_helper_crypto_sha256su1(ptr1, ptr2, ptr3); | ||
367 | - tcg_temp_free_ptr(ptr1); | ||
368 | - tcg_temp_free_ptr(ptr2); | ||
369 | - tcg_temp_free_ptr(ptr3); | ||
370 | - | ||
371 | - return true; | ||
372 | -} | ||
373 | +DO_SHA2(SHA256H, gen_helper_crypto_sha256h) | ||
374 | +DO_SHA2(SHA256H2, gen_helper_crypto_sha256h2) | ||
375 | +DO_SHA2(SHA256SU1, gen_helper_crypto_sha256su1) | ||
376 | |||
377 | #define DO_3SAME_64(INSN, FUNC) \ | ||
378 | static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | ||
379 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
380 | index XXXXXXX..XXXXXXX 100644 | ||
381 | --- a/target/arm/translate.c | ||
382 | +++ b/target/arm/translate.c | ||
383 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
384 | int vec_size; | ||
385 | uint32_t imm; | ||
386 | TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5; | ||
387 | - TCGv_ptr ptr1, ptr2; | ||
388 | + TCGv_ptr ptr1; | ||
389 | TCGv_i64 tmp64; | ||
390 | |||
391 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
392 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
393 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
394 | return 1; | ||
395 | } | ||
396 | - ptr1 = vfp_reg_ptr(true, rd); | ||
397 | - ptr2 = vfp_reg_ptr(true, rm); | ||
398 | - | ||
399 | - gen_helper_crypto_sha1h(ptr1, ptr2); | ||
400 | - | ||
401 | - tcg_temp_free_ptr(ptr1); | ||
402 | - tcg_temp_free_ptr(ptr2); | ||
403 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
404 | + gen_helper_crypto_sha1h); | ||
405 | break; | ||
406 | case NEON_2RM_SHA1SU1: | ||
407 | if ((rm | rd) & 1) { | ||
408 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
409 | } else if (!dc_isar_feature(aa32_sha1, s)) { | ||
410 | return 1; | ||
411 | } | ||
412 | - ptr1 = vfp_reg_ptr(true, rd); | ||
413 | - ptr2 = vfp_reg_ptr(true, rm); | ||
414 | - if (q) { | ||
415 | - gen_helper_crypto_sha256su0(ptr1, ptr2); | ||
416 | - } else { | ||
417 | - gen_helper_crypto_sha1su1(ptr1, ptr2); | ||
418 | - } | ||
419 | - tcg_temp_free_ptr(ptr1); | ||
420 | - tcg_temp_free_ptr(ptr2); | ||
421 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
422 | + q ? gen_helper_crypto_sha256su0 | ||
423 | + : gen_helper_crypto_sha1su1); | ||
424 | break; | ||
425 | - | ||
426 | case NEON_2RM_VMVN: | ||
427 | tcg_gen_gvec_not(0, rd_ofs, rm_ofs, vec_size, vec_size); | ||
428 | break; | ||
429 | -- | 73 | -- |
430 | 2.20.1 | 74 | 2.25.1 |
431 | 75 | ||
432 | 76 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller state definitions. | 3 | So far the GPT timers were unable to raise IRQs to the processor. |
4 | Mostly based on hw/usb/hcd-ehci.h. | ||
5 | 4 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 5 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
7 | Message-id: 20200520235349.21215-4-pauldzim@gmail.com | ||
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 | hw/usb/hcd-dwc2.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++ | 9 | include/hw/arm/fsl-imx7.h | 5 +++++ |
12 | 1 file changed, 190 insertions(+) | 10 | hw/arm/fsl-imx7.c | 10 ++++++++++ |
13 | create mode 100644 hw/usb/hcd-dwc2.h | 11 | 2 files changed, 15 insertions(+) |
14 | 12 | ||
15 | diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h | 13 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
16 | new file mode 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 15 | --- a/include/hw/arm/fsl-imx7.h |
18 | --- /dev/null | 16 | +++ b/include/hw/arm/fsl-imx7.h |
19 | +++ b/hw/usb/hcd-dwc2.h | 17 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
20 | @@ -XXX,XX +XXX,XX @@ | 18 | FSL_IMX7_USB2_IRQ = 42, |
21 | +/* | 19 | FSL_IMX7_USB3_IRQ = 40, |
22 | + * dwc-hsotg (dwc2) USB host controller state definitions | 20 | |
23 | + * | 21 | + FSL_IMX7_GPT1_IRQ = 55, |
24 | + * Based on hw/usb/hcd-ehci.h | 22 | + FSL_IMX7_GPT2_IRQ = 54, |
25 | + * | 23 | + FSL_IMX7_GPT3_IRQ = 53, |
26 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | 24 | + FSL_IMX7_GPT4_IRQ = 52, |
27 | + * | ||
28 | + * This program is free software; you can redistribute it and/or modify | ||
29 | + * it under the terms of the GNU General Public License as published by | ||
30 | + * the Free Software Foundation; either version 2 of the License, or | ||
31 | + * (at your option) any later version. | ||
32 | + * | ||
33 | + * This program is distributed in the hope that it will be useful, | ||
34 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
35 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
36 | + * GNU General Public License for more details. | ||
37 | + */ | ||
38 | + | 25 | + |
39 | +#ifndef HW_USB_DWC2_H | 26 | FSL_IMX7_WDOG1_IRQ = 78, |
40 | +#define HW_USB_DWC2_H | 27 | FSL_IMX7_WDOG2_IRQ = 79, |
28 | FSL_IMX7_WDOG3_IRQ = 10, | ||
29 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/fsl-imx7.c | ||
32 | +++ b/hw/arm/fsl-imx7.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
34 | FSL_IMX7_GPT4_ADDR, | ||
35 | }; | ||
36 | |||
37 | + static const int FSL_IMX7_GPTn_IRQ[FSL_IMX7_NUM_GPTS] = { | ||
38 | + FSL_IMX7_GPT1_IRQ, | ||
39 | + FSL_IMX7_GPT2_IRQ, | ||
40 | + FSL_IMX7_GPT3_IRQ, | ||
41 | + FSL_IMX7_GPT4_IRQ, | ||
42 | + }; | ||
41 | + | 43 | + |
42 | +#include "qemu/timer.h" | 44 | s->gpt[i].ccm = IMX_CCM(&s->ccm); |
43 | +#include "hw/irq.h" | 45 | sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &error_abort); |
44 | +#include "hw/sysbus.h" | 46 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, FSL_IMX7_GPTn_ADDR[i]); |
45 | +#include "hw/usb.h" | 47 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0, |
46 | +#include "sysemu/dma.h" | 48 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
47 | + | 49 | + FSL_IMX7_GPTn_IRQ[i])); |
48 | +#define DWC2_MMIO_SIZE 0x11000 | 50 | } |
49 | + | 51 | |
50 | +#define DWC2_NB_CHAN 8 /* Number of host channels */ | 52 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { |
51 | +#define DWC2_MAX_XFER_SIZE 65536 /* Max transfer size expected in HCTSIZ */ | ||
52 | + | ||
53 | +typedef struct DWC2Packet DWC2Packet; | ||
54 | +typedef struct DWC2State DWC2State; | ||
55 | +typedef struct DWC2Class DWC2Class; | ||
56 | + | ||
57 | +enum async_state { | ||
58 | + DWC2_ASYNC_NONE = 0, | ||
59 | + DWC2_ASYNC_INITIALIZED, | ||
60 | + DWC2_ASYNC_INFLIGHT, | ||
61 | + DWC2_ASYNC_FINISHED, | ||
62 | +}; | ||
63 | + | ||
64 | +struct DWC2Packet { | ||
65 | + USBPacket packet; | ||
66 | + uint32_t devadr; | ||
67 | + uint32_t epnum; | ||
68 | + uint32_t epdir; | ||
69 | + uint32_t mps; | ||
70 | + uint32_t pid; | ||
71 | + uint32_t index; | ||
72 | + uint32_t pcnt; | ||
73 | + uint32_t len; | ||
74 | + int32_t async; | ||
75 | + bool small; | ||
76 | + bool needs_service; | ||
77 | +}; | ||
78 | + | ||
79 | +struct DWC2State { | ||
80 | + /*< private >*/ | ||
81 | + SysBusDevice parent_obj; | ||
82 | + | ||
83 | + /*< public >*/ | ||
84 | + USBBus bus; | ||
85 | + qemu_irq irq; | ||
86 | + MemoryRegion *dma_mr; | ||
87 | + AddressSpace dma_as; | ||
88 | + MemoryRegion container; | ||
89 | + MemoryRegion hsotg; | ||
90 | + MemoryRegion fifos; | ||
91 | + | ||
92 | + union { | ||
93 | +#define DWC2_GLBREG_SIZE 0x70 | ||
94 | + uint32_t glbreg[DWC2_GLBREG_SIZE / sizeof(uint32_t)]; | ||
95 | + struct { | ||
96 | + uint32_t gotgctl; /* 00 */ | ||
97 | + uint32_t gotgint; /* 04 */ | ||
98 | + uint32_t gahbcfg; /* 08 */ | ||
99 | + uint32_t gusbcfg; /* 0c */ | ||
100 | + uint32_t grstctl; /* 10 */ | ||
101 | + uint32_t gintsts; /* 14 */ | ||
102 | + uint32_t gintmsk; /* 18 */ | ||
103 | + uint32_t grxstsr; /* 1c */ | ||
104 | + uint32_t grxstsp; /* 20 */ | ||
105 | + uint32_t grxfsiz; /* 24 */ | ||
106 | + uint32_t gnptxfsiz; /* 28 */ | ||
107 | + uint32_t gnptxsts; /* 2c */ | ||
108 | + uint32_t gi2cctl; /* 30 */ | ||
109 | + uint32_t gpvndctl; /* 34 */ | ||
110 | + uint32_t ggpio; /* 38 */ | ||
111 | + uint32_t guid; /* 3c */ | ||
112 | + uint32_t gsnpsid; /* 40 */ | ||
113 | + uint32_t ghwcfg1; /* 44 */ | ||
114 | + uint32_t ghwcfg2; /* 48 */ | ||
115 | + uint32_t ghwcfg3; /* 4c */ | ||
116 | + uint32_t ghwcfg4; /* 50 */ | ||
117 | + uint32_t glpmcfg; /* 54 */ | ||
118 | + uint32_t gpwrdn; /* 58 */ | ||
119 | + uint32_t gdfifocfg; /* 5c */ | ||
120 | + uint32_t gadpctl; /* 60 */ | ||
121 | + uint32_t grefclk; /* 64 */ | ||
122 | + uint32_t gintmsk2; /* 68 */ | ||
123 | + uint32_t gintsts2; /* 6c */ | ||
124 | + }; | ||
125 | + }; | ||
126 | + | ||
127 | + union { | ||
128 | +#define DWC2_FSZREG_SIZE 0x04 | ||
129 | + uint32_t fszreg[DWC2_FSZREG_SIZE / sizeof(uint32_t)]; | ||
130 | + struct { | ||
131 | + uint32_t hptxfsiz; /* 100 */ | ||
132 | + }; | ||
133 | + }; | ||
134 | + | ||
135 | + union { | ||
136 | +#define DWC2_HREG0_SIZE 0x44 | ||
137 | + uint32_t hreg0[DWC2_HREG0_SIZE / sizeof(uint32_t)]; | ||
138 | + struct { | ||
139 | + uint32_t hcfg; /* 400 */ | ||
140 | + uint32_t hfir; /* 404 */ | ||
141 | + uint32_t hfnum; /* 408 */ | ||
142 | + uint32_t rsvd0; /* 40c */ | ||
143 | + uint32_t hptxsts; /* 410 */ | ||
144 | + uint32_t haint; /* 414 */ | ||
145 | + uint32_t haintmsk; /* 418 */ | ||
146 | + uint32_t hflbaddr; /* 41c */ | ||
147 | + uint32_t rsvd1[8]; /* 420-43c */ | ||
148 | + uint32_t hprt0; /* 440 */ | ||
149 | + }; | ||
150 | + }; | ||
151 | + | ||
152 | +#define DWC2_HREG1_SIZE (0x20 * DWC2_NB_CHAN) | ||
153 | + uint32_t hreg1[DWC2_HREG1_SIZE / sizeof(uint32_t)]; | ||
154 | + | ||
155 | +#define hcchar(_ch) hreg1[((_ch) << 3) + 0] /* 500, 520, ... */ | ||
156 | +#define hcsplt(_ch) hreg1[((_ch) << 3) + 1] /* 504, 524, ... */ | ||
157 | +#define hcint(_ch) hreg1[((_ch) << 3) + 2] /* 508, 528, ... */ | ||
158 | +#define hcintmsk(_ch) hreg1[((_ch) << 3) + 3] /* 50c, 52c, ... */ | ||
159 | +#define hctsiz(_ch) hreg1[((_ch) << 3) + 4] /* 510, 530, ... */ | ||
160 | +#define hcdma(_ch) hreg1[((_ch) << 3) + 5] /* 514, 534, ... */ | ||
161 | +#define hcdmab(_ch) hreg1[((_ch) << 3) + 7] /* 51c, 53c, ... */ | ||
162 | + | ||
163 | + union { | ||
164 | +#define DWC2_PCGREG_SIZE 0x08 | ||
165 | + uint32_t pcgreg[DWC2_PCGREG_SIZE / sizeof(uint32_t)]; | ||
166 | + struct { | ||
167 | + uint32_t pcgctl; /* e00 */ | ||
168 | + uint32_t pcgcctl1; /* e04 */ | ||
169 | + }; | ||
170 | + }; | ||
171 | + | ||
172 | + /* TODO - implement FIFO registers for slave mode */ | ||
173 | +#define DWC2_HFIFO_SIZE (0x1000 * DWC2_NB_CHAN) | ||
174 | + | ||
175 | + /* | ||
176 | + * Internal state | ||
177 | + */ | ||
178 | + QEMUTimer *eof_timer; | ||
179 | + QEMUTimer *frame_timer; | ||
180 | + QEMUBH *async_bh; | ||
181 | + int64_t sof_time; | ||
182 | + int64_t usb_frame_time; | ||
183 | + int64_t usb_bit_time; | ||
184 | + uint32_t usb_version; | ||
185 | + uint16_t frame_number; | ||
186 | + uint16_t fi; | ||
187 | + uint16_t next_chan; | ||
188 | + bool working; | ||
189 | + USBPort uport; | ||
190 | + DWC2Packet packet[DWC2_NB_CHAN]; /* one packet per chan */ | ||
191 | + uint8_t usb_buf[DWC2_NB_CHAN][DWC2_MAX_XFER_SIZE]; /* one buffer per chan */ | ||
192 | +}; | ||
193 | + | ||
194 | +struct DWC2Class { | ||
195 | + /*< private >*/ | ||
196 | + SysBusDeviceClass parent_class; | ||
197 | + ResettablePhases parent_phases; | ||
198 | + | ||
199 | + /*< public >*/ | ||
200 | +}; | ||
201 | + | ||
202 | +#define TYPE_DWC2_USB "dwc2-usb" | ||
203 | +#define DWC2_USB(obj) \ | ||
204 | + OBJECT_CHECK(DWC2State, (obj), TYPE_DWC2_USB) | ||
205 | +#define DWC2_CLASS(klass) \ | ||
206 | + OBJECT_CLASS_CHECK(DWC2Class, (klass), TYPE_DWC2_USB) | ||
207 | +#define DWC2_GET_CLASS(obj) \ | ||
208 | + OBJECT_GET_CLASS(DWC2Class, (obj), TYPE_DWC2_USB) | ||
209 | + | ||
210 | +#endif | ||
211 | -- | 53 | -- |
212 | 2.20.1 | 54 | 2.25.1 |
213 | |||
214 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Add BCM2835 SOC MPHI (Message-based Parallel Host Interface) | 3 | CCM derived clocks will have to be added later. |
4 | emulation. It is very basic, only providing the FIQ interrupt | ||
5 | needed to allow the dwc-otg USB host controller driver in the | ||
6 | Raspbian kernel to function. | ||
7 | 4 | ||
8 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 5 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
9 | Acked-by: Philippe Mathieu-Daude <f4bug@amsat.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20200520235349.21215-2-pauldzim@gmail.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 8 | --- |
14 | include/hw/arm/bcm2835_peripherals.h | 2 + | 9 | hw/misc/imx7_ccm.c | 49 +++++++++++++++++++++++++++++++++++++--------- |
15 | include/hw/misc/bcm2835_mphi.h | 44 ++++++ | 10 | 1 file changed, 40 insertions(+), 9 deletions(-) |
16 | hw/arm/bcm2835_peripherals.c | 17 +++ | ||
17 | hw/misc/bcm2835_mphi.c | 191 +++++++++++++++++++++++++++ | ||
18 | hw/misc/Makefile.objs | 1 + | ||
19 | 5 files changed, 255 insertions(+) | ||
20 | create mode 100644 include/hw/misc/bcm2835_mphi.h | ||
21 | create mode 100644 hw/misc/bcm2835_mphi.c | ||
22 | 11 | ||
23 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 12 | diff --git a/hw/misc/imx7_ccm.c b/hw/misc/imx7_ccm.c |
24 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/bcm2835_peripherals.h | 14 | --- a/hw/misc/imx7_ccm.c |
26 | +++ b/include/hw/arm/bcm2835_peripherals.h | 15 | +++ b/hw/misc/imx7_ccm.c |
27 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
28 | #include "hw/misc/bcm2835_property.h" | 17 | #include "hw/misc/imx7_ccm.h" |
29 | #include "hw/misc/bcm2835_rng.h" | 18 | #include "migration/vmstate.h" |
30 | #include "hw/misc/bcm2835_mbox.h" | 19 | |
31 | +#include "hw/misc/bcm2835_mphi.h" | 20 | +#include "trace.h" |
32 | #include "hw/misc/bcm2835_thermal.h" | ||
33 | #include "hw/sd/sdhci.h" | ||
34 | #include "hw/sd/bcm2835_sdhost.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | ||
36 | qemu_irq irq, fiq; | ||
37 | |||
38 | BCM2835SystemTimerState systmr; | ||
39 | + BCM2835MphiState mphi; | ||
40 | UnimplementedDeviceState armtmr; | ||
41 | UnimplementedDeviceState cprman; | ||
42 | UnimplementedDeviceState a2w; | ||
43 | diff --git a/include/hw/misc/bcm2835_mphi.h b/include/hw/misc/bcm2835_mphi.h | ||
44 | new file mode 100644 | ||
45 | index XXXXXXX..XXXXXXX | ||
46 | --- /dev/null | ||
47 | +++ b/include/hw/misc/bcm2835_mphi.h | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | +/* | ||
50 | + * BCM2835 SOC MPHI state definitions | ||
51 | + * | ||
52 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
53 | + * | ||
54 | + * This program is free software; you can redistribute it and/or modify | ||
55 | + * it under the terms of the GNU General Public License as published by | ||
56 | + * the Free Software Foundation; either version 2 of the License, or | ||
57 | + * (at your option) any later version. | ||
58 | + * | ||
59 | + * This program is distributed in the hope that it will be useful, | ||
60 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
61 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
62 | + * GNU General Public License for more details. | ||
63 | + */ | ||
64 | + | 21 | + |
65 | +#ifndef HW_MISC_BCM2835_MPHI_H | 22 | +#define CKIH_FREQ 24000000 /* 24MHz crystal input */ |
66 | +#define HW_MISC_BCM2835_MPHI_H | ||
67 | + | 23 | + |
68 | +#include "hw/irq.h" | 24 | static void imx7_analog_reset(DeviceState *dev) |
69 | +#include "hw/sysbus.h" | 25 | { |
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; | ||
70 | + | 48 | + |
71 | +#define MPHI_MMIO_SIZE 0x1000 | 49 | + switch (clock) { |
72 | + | 50 | + case CLK_NONE: |
73 | +typedef struct BCM2835MphiState BCM2835MphiState; | ||
74 | + | ||
75 | +struct BCM2835MphiState { | ||
76 | + SysBusDevice parent_obj; | ||
77 | + qemu_irq irq; | ||
78 | + MemoryRegion iomem; | ||
79 | + | ||
80 | + uint32_t outdda; | ||
81 | + uint32_t outddb; | ||
82 | + uint32_t ctrl; | ||
83 | + uint32_t intstat; | ||
84 | + uint32_t swirq; | ||
85 | +}; | ||
86 | + | ||
87 | +#define TYPE_BCM2835_MPHI "bcm2835-mphi" | ||
88 | + | ||
89 | +#define BCM2835_MPHI(obj) \ | ||
90 | + OBJECT_CHECK(BCM2835MphiState, (obj), TYPE_BCM2835_MPHI) | ||
91 | + | ||
92 | +#endif | ||
93 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/arm/bcm2835_peripherals.c | ||
96 | +++ b/hw/arm/bcm2835_peripherals.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
98 | OBJECT(&s->sdhci.sdbus)); | ||
99 | object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", | ||
100 | OBJECT(&s->sdhost.sdbus)); | ||
101 | + | ||
102 | + /* Mphi */ | ||
103 | + sysbus_init_child_obj(obj, "mphi", &s->mphi, sizeof(s->mphi), | ||
104 | + TYPE_BCM2835_MPHI); | ||
105 | } | ||
106 | |||
107 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
108 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
109 | |||
110 | object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | ||
111 | |||
112 | + /* Mphi */ | ||
113 | + object_property_set_bool(OBJECT(&s->mphi), true, "realized", &err); | ||
114 | + if (err) { | ||
115 | + error_propagate(errp, err); | ||
116 | + return; | ||
117 | + } | ||
118 | + | ||
119 | + memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET, | ||
120 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0)); | ||
121 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0, | ||
122 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
123 | + INTERRUPT_HOSTPORT)); | ||
124 | + | ||
125 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
126 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
127 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
128 | diff --git a/hw/misc/bcm2835_mphi.c b/hw/misc/bcm2835_mphi.c | ||
129 | new file mode 100644 | ||
130 | index XXXXXXX..XXXXXXX | ||
131 | --- /dev/null | ||
132 | +++ b/hw/misc/bcm2835_mphi.c | ||
133 | @@ -XXX,XX +XXX,XX @@ | ||
134 | +/* | ||
135 | + * BCM2835 SOC MPHI emulation | ||
136 | + * | ||
137 | + * Very basic emulation, only providing the FIQ interrupt needed to | ||
138 | + * allow the dwc-otg USB host controller driver in the Raspbian kernel | ||
139 | + * to function. | ||
140 | + * | ||
141 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
142 | + * | ||
143 | + * This program is free software; you can redistribute it and/or modify | ||
144 | + * it under the terms of the GNU General Public License as published by | ||
145 | + * the Free Software Foundation; either version 2 of the License, or | ||
146 | + * (at your option) any later version. | ||
147 | + * | ||
148 | + * This program is distributed in the hope that it will be useful, | ||
149 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
150 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
151 | + * GNU General Public License for more details. | ||
152 | + */ | ||
153 | + | ||
154 | +#include "qemu/osdep.h" | ||
155 | +#include "qapi/error.h" | ||
156 | +#include "hw/misc/bcm2835_mphi.h" | ||
157 | +#include "migration/vmstate.h" | ||
158 | +#include "qemu/error-report.h" | ||
159 | +#include "qemu/log.h" | ||
160 | +#include "qemu/main-loop.h" | ||
161 | + | ||
162 | +static inline void mphi_raise_irq(BCM2835MphiState *s) | ||
163 | +{ | ||
164 | + qemu_set_irq(s->irq, 1); | ||
165 | +} | ||
166 | + | ||
167 | +static inline void mphi_lower_irq(BCM2835MphiState *s) | ||
168 | +{ | ||
169 | + qemu_set_irq(s->irq, 0); | ||
170 | +} | ||
171 | + | ||
172 | +static uint64_t mphi_reg_read(void *ptr, hwaddr addr, unsigned size) | ||
173 | +{ | ||
174 | + BCM2835MphiState *s = ptr; | ||
175 | + uint32_t val = 0; | ||
176 | + | ||
177 | + switch (addr) { | ||
178 | + case 0x28: /* outdda */ | ||
179 | + val = s->outdda; | ||
180 | + break; | 51 | + break; |
181 | + case 0x2c: /* outddb */ | 52 | + case CLK_32k: |
182 | + val = s->outddb; | 53 | + freq = CKIL_FREQ; |
183 | + break; | 54 | + break; |
184 | + case 0x4c: /* ctrl */ | 55 | + case CLK_HIGH: |
185 | + val = s->ctrl; | 56 | + freq = CKIH_FREQ; |
186 | + val |= 1 << 17; | ||
187 | + break; | 57 | + break; |
188 | + case 0x50: /* intstat */ | 58 | + case CLK_IPG: |
189 | + val = s->intstat; | 59 | + case CLK_IPG_HIGH: |
190 | + break; | 60 | + /* |
191 | + case 0x1f0: /* swirq_set */ | 61 | + * For now we don't have a way to figure out the device this |
192 | + val = s->swirq; | 62 | + * function is called for. Until then the IPG derived clocks |
193 | + break; | 63 | + * are left unimplemented. |
194 | + case 0x1f4: /* swirq_clr */ | 64 | + */ |
195 | + val = s->swirq; | 65 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Clock %d Not implemented\n", |
66 | + TYPE_IMX7_CCM, __func__, clock); | ||
196 | + break; | 67 | + break; |
197 | + default: | 68 | + default: |
198 | + qemu_log_mask(LOG_UNIMP, "read from unknown register"); | 69 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n", |
70 | + TYPE_IMX7_CCM, __func__, clock); | ||
199 | + break; | 71 | + break; |
200 | + } | 72 | + } |
201 | + | 73 | + |
202 | + return val; | 74 | + trace_ccm_clock_freq(clock, freq); |
203 | +} | ||
204 | + | 75 | + |
205 | +static void mphi_reg_write(void *ptr, hwaddr addr, uint64_t val, unsigned size) | 76 | + return freq; |
206 | +{ | 77 | } |
207 | + BCM2835MphiState *s = ptr; | 78 | |
208 | + int do_irq = 0; | 79 | static void imx7_ccm_class_init(ObjectClass *klass, void *data) |
209 | + | ||
210 | + switch (addr) { | ||
211 | + case 0x28: /* outdda */ | ||
212 | + s->outdda = val; | ||
213 | + break; | ||
214 | + case 0x2c: /* outddb */ | ||
215 | + s->outddb = val; | ||
216 | + if (val & (1 << 29)) { | ||
217 | + do_irq = 1; | ||
218 | + } | ||
219 | + break; | ||
220 | + case 0x4c: /* ctrl */ | ||
221 | + s->ctrl = val; | ||
222 | + if (val & (1 << 16)) { | ||
223 | + do_irq = -1; | ||
224 | + } | ||
225 | + break; | ||
226 | + case 0x50: /* intstat */ | ||
227 | + s->intstat = val; | ||
228 | + if (val & ((1 << 16) | (1 << 29))) { | ||
229 | + do_irq = -1; | ||
230 | + } | ||
231 | + break; | ||
232 | + case 0x1f0: /* swirq_set */ | ||
233 | + s->swirq |= val; | ||
234 | + do_irq = 1; | ||
235 | + break; | ||
236 | + case 0x1f4: /* swirq_clr */ | ||
237 | + s->swirq &= ~val; | ||
238 | + do_irq = -1; | ||
239 | + break; | ||
240 | + default: | ||
241 | + qemu_log_mask(LOG_UNIMP, "write to unknown register"); | ||
242 | + return; | ||
243 | + } | ||
244 | + | ||
245 | + if (do_irq > 0) { | ||
246 | + mphi_raise_irq(s); | ||
247 | + } else if (do_irq < 0) { | ||
248 | + mphi_lower_irq(s); | ||
249 | + } | ||
250 | +} | ||
251 | + | ||
252 | +static const MemoryRegionOps mphi_mmio_ops = { | ||
253 | + .read = mphi_reg_read, | ||
254 | + .write = mphi_reg_write, | ||
255 | + .impl.min_access_size = 4, | ||
256 | + .impl.max_access_size = 4, | ||
257 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
258 | +}; | ||
259 | + | ||
260 | +static void mphi_reset(DeviceState *dev) | ||
261 | +{ | ||
262 | + BCM2835MphiState *s = BCM2835_MPHI(dev); | ||
263 | + | ||
264 | + s->outdda = 0; | ||
265 | + s->outddb = 0; | ||
266 | + s->ctrl = 0; | ||
267 | + s->intstat = 0; | ||
268 | + s->swirq = 0; | ||
269 | +} | ||
270 | + | ||
271 | +static void mphi_realize(DeviceState *dev, Error **errp) | ||
272 | +{ | ||
273 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
274 | + BCM2835MphiState *s = BCM2835_MPHI(dev); | ||
275 | + | ||
276 | + sysbus_init_irq(sbd, &s->irq); | ||
277 | +} | ||
278 | + | ||
279 | +static void mphi_init(Object *obj) | ||
280 | +{ | ||
281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
282 | + BCM2835MphiState *s = BCM2835_MPHI(obj); | ||
283 | + | ||
284 | + memory_region_init_io(&s->iomem, obj, &mphi_mmio_ops, s, "mphi", MPHI_MMIO_SIZE); | ||
285 | + sysbus_init_mmio(sbd, &s->iomem); | ||
286 | +} | ||
287 | + | ||
288 | +const VMStateDescription vmstate_mphi_state = { | ||
289 | + .name = "mphi", | ||
290 | + .version_id = 1, | ||
291 | + .minimum_version_id = 1, | ||
292 | + .fields = (VMStateField[]) { | ||
293 | + VMSTATE_UINT32(outdda, BCM2835MphiState), | ||
294 | + VMSTATE_UINT32(outddb, BCM2835MphiState), | ||
295 | + VMSTATE_UINT32(ctrl, BCM2835MphiState), | ||
296 | + VMSTATE_UINT32(intstat, BCM2835MphiState), | ||
297 | + VMSTATE_UINT32(swirq, BCM2835MphiState), | ||
298 | + VMSTATE_END_OF_LIST() | ||
299 | + } | ||
300 | +}; | ||
301 | + | ||
302 | +static void mphi_class_init(ObjectClass *klass, void *data) | ||
303 | +{ | ||
304 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
305 | + | ||
306 | + dc->realize = mphi_realize; | ||
307 | + dc->reset = mphi_reset; | ||
308 | + dc->vmsd = &vmstate_mphi_state; | ||
309 | +} | ||
310 | + | ||
311 | +static const TypeInfo bcm2835_mphi_type_info = { | ||
312 | + .name = TYPE_BCM2835_MPHI, | ||
313 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
314 | + .instance_size = sizeof(BCM2835MphiState), | ||
315 | + .instance_init = mphi_init, | ||
316 | + .class_init = mphi_class_init, | ||
317 | +}; | ||
318 | + | ||
319 | +static void bcm2835_mphi_register_types(void) | ||
320 | +{ | ||
321 | + type_register_static(&bcm2835_mphi_type_info); | ||
322 | +} | ||
323 | + | ||
324 | +type_init(bcm2835_mphi_register_types) | ||
325 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
326 | index XXXXXXX..XXXXXXX 100644 | ||
327 | --- a/hw/misc/Makefile.objs | ||
328 | +++ b/hw/misc/Makefile.objs | ||
329 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_OMAP) += omap_l4.o | ||
330 | common-obj-$(CONFIG_OMAP) += omap_sdrc.o | ||
331 | common-obj-$(CONFIG_OMAP) += omap_tap.o | ||
332 | common-obj-$(CONFIG_RASPI) += bcm2835_mbox.o | ||
333 | +common-obj-$(CONFIG_RASPI) += bcm2835_mphi.o | ||
334 | common-obj-$(CONFIG_RASPI) += bcm2835_property.o | ||
335 | common-obj-$(CONFIG_RASPI) += bcm2835_rng.o | ||
336 | common-obj-$(CONFIG_RASPI) += bcm2835_thermal.o | ||
337 | -- | 80 | -- |
338 | 2.20.1 | 81 | 2.25.1 |
339 | |||
340 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Rather than passing an opcode to a helper, fully decode the | 3 | The i.MX6UL doesn't support CLK_HIGH ou CLK_HIGH_DIV clock source. |
4 | operation at translate time. Use clear_tail_16 to zap the | ||
5 | balance of the SVE register with the AdvSIMD write. | ||
6 | 4 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
8 | Message-id: 20200514212831.31248-6-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 8 | --- |
12 | target/arm/helper.h | 5 +- | 9 | include/hw/timer/imx_gpt.h | 1 + |
13 | target/arm/neon-dp.decode | 6 +- | 10 | hw/arm/fsl-imx6ul.c | 2 +- |
14 | target/arm/crypto_helper.c | 99 +++++++++++++++++++++------------ | 11 | hw/misc/imx6ul_ccm.c | 6 ------ |
15 | target/arm/translate-a64.c | 29 ++++------ | 12 | hw/timer/imx_gpt.c | 25 +++++++++++++++++++++++++ |
16 | target/arm/translate-neon.inc.c | 46 ++++----------- | 13 | 4 files changed, 27 insertions(+), 7 deletions(-) |
17 | 5 files changed, 93 insertions(+), 92 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 15 | diff --git a/include/hw/timer/imx_gpt.h b/include/hw/timer/imx_gpt.h |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.h | 17 | --- a/include/hw/timer/imx_gpt.h |
22 | +++ b/target/arm/helper.h | 18 | +++ b/include/hw/timer/imx_gpt.h |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ |
24 | DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 20 | #define TYPE_IMX25_GPT "imx25.gpt" |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 21 | #define TYPE_IMX31_GPT "imx31.gpt" |
26 | 22 | #define TYPE_IMX6_GPT "imx6.gpt" | |
27 | -DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 23 | +#define TYPE_IMX6UL_GPT "imx6ul.gpt" |
28 | +DEF_HELPER_FLAGS_4(crypto_sha1su0, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 24 | #define TYPE_IMX7_GPT "imx7.gpt" |
29 | +DEF_HELPER_FLAGS_4(crypto_sha1c, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 25 | |
30 | +DEF_HELPER_FLAGS_4(crypto_sha1p, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 26 | #define TYPE_IMX_GPT TYPE_IMX25_GPT |
31 | +DEF_HELPER_FLAGS_4(crypto_sha1m, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 27 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
32 | DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
33 | DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
34 | |||
35 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
36 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/neon-dp.decode | 29 | --- a/hw/arm/fsl-imx6ul.c |
38 | +++ b/target/arm/neon-dp.decode | 30 | +++ b/hw/arm/fsl-imx6ul.c |
39 | @@ -XXX,XX +XXX,XX @@ VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | 31 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) |
40 | @3same_crypto .... .... .... .... .... .... .... .... \ | 32 | */ |
41 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | 33 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { |
42 | 34 | snprintf(name, NAME_SIZE, "gpt%d", i); | |
43 | -SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | 35 | - object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX7_GPT); |
44 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 36 | + object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX6UL_GPT); |
45 | +SHA1C_3s 1111 001 0 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | 37 | } |
46 | +SHA1P_3s 1111 001 0 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | 38 | |
47 | +SHA1M_3s 1111 001 0 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | 39 | /* |
48 | +SHA1SU0_3s 1111 001 0 0 . 11 .... .... 1100 . 1 . 0 .... @3same_crypto | 40 | diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c |
49 | SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
50 | SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
51 | SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
52 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
54 | --- a/target/arm/crypto_helper.c | 42 | --- a/hw/misc/imx6ul_ccm.c |
55 | +++ b/target/arm/crypto_helper.c | 43 | +++ b/hw/misc/imx6ul_ccm.c |
56 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | 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 */ | ||
57 | }; | 63 | }; |
58 | 64 | ||
59 | #ifdef HOST_WORDS_BIGENDIAN | 65 | +static const IMXClk imx6ul_gpt_clocks[] = { |
60 | -#define CR_ST_BYTE(state, i) (state.bytes[(15 - (i)) ^ 8]) | 66 | + CLK_NONE, /* 000 No clock source */ |
61 | -#define CR_ST_WORD(state, i) (state.words[(3 - (i)) ^ 2]) | 67 | + CLK_IPG, /* 001 ipg_clk, 532MHz*/ |
62 | +#define CR_ST_BYTE(state, i) ((state).bytes[(15 - (i)) ^ 8]) | 68 | + CLK_IPG_HIGH, /* 010 ipg_clk_highfreq */ |
63 | +#define CR_ST_WORD(state, i) ((state).words[(3 - (i)) ^ 2]) | 69 | + CLK_EXT, /* 011 External clock */ |
64 | #else | 70 | + CLK_32k, /* 100 ipg_clk_32k */ |
65 | -#define CR_ST_BYTE(state, i) (state.bytes[i]) | 71 | + CLK_NONE, /* 101 not defined */ |
66 | -#define CR_ST_WORD(state, i) (state.words[i]) | 72 | + CLK_NONE, /* 110 not defined */ |
67 | +#define CR_ST_BYTE(state, i) ((state).bytes[i]) | 73 | + CLK_NONE, /* 111 not defined */ |
68 | +#define CR_ST_WORD(state, i) ((state).words[i]) | 74 | +}; |
69 | #endif | 75 | + |
70 | 76 | static const IMXClk imx7_gpt_clocks[] = { | |
71 | /* | 77 | CLK_NONE, /* 000 No clock source */ |
72 | @@ -XXX,XX +XXX,XX @@ static uint32_t maj(uint32_t x, uint32_t y, uint32_t z) | 78 | CLK_IPG, /* 001 ipg_clk, 532MHz*/ |
73 | return (x & y) | ((x | y) & z); | 79 | @@ -XXX,XX +XXX,XX @@ static void imx6_gpt_init(Object *obj) |
80 | s->clocks = imx6_gpt_clocks; | ||
74 | } | 81 | } |
75 | 82 | ||
76 | -void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | 83 | +static void imx6ul_gpt_init(Object *obj) |
77 | +void HELPER(crypto_sha1su0)(void *vd, void *vn, void *vm, uint32_t desc) | ||
78 | +{ | 84 | +{ |
79 | + uint64_t *d = vd, *n = vn, *m = vm; | 85 | + IMXGPTState *s = IMX_GPT(obj); |
80 | + uint64_t d0, d1; | ||
81 | + | 86 | + |
82 | + d0 = d[1] ^ d[0] ^ m[0]; | 87 | + s->clocks = imx6ul_gpt_clocks; |
83 | + d1 = n[0] ^ d[1] ^ m[1]; | ||
84 | + d[0] = d0; | ||
85 | + d[1] = d1; | ||
86 | + | ||
87 | + clear_tail_16(vd, desc); | ||
88 | +} | 88 | +} |
89 | + | 89 | + |
90 | +static inline void crypto_sha1_3reg(uint64_t *rd, uint64_t *rn, | 90 | static void imx7_gpt_init(Object *obj) |
91 | + uint64_t *rm, uint32_t desc, | ||
92 | + uint32_t (*fn)(union CRYPTO_STATE *d)) | ||
93 | { | 91 | { |
94 | - uint64_t *rd = vd; | 92 | IMXGPTState *s = IMX_GPT(obj); |
95 | - uint64_t *rn = vn; | 93 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo imx6_gpt_info = { |
96 | - uint64_t *rm = vm; | 94 | .instance_init = imx6_gpt_init, |
97 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | 95 | }; |
98 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | 96 | |
99 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | 97 | +static const TypeInfo imx6ul_gpt_info = { |
100 | + int i; | 98 | + .name = TYPE_IMX6UL_GPT, |
101 | 99 | + .parent = TYPE_IMX25_GPT, | |
102 | - if (op == 3) { /* sha1su0 */ | 100 | + .instance_init = imx6ul_gpt_init, |
103 | - d.l[0] ^= d.l[1] ^ m.l[0]; | 101 | +}; |
104 | - d.l[1] ^= n.l[0] ^ m.l[1]; | ||
105 | - } else { | ||
106 | - int i; | ||
107 | + for (i = 0; i < 4; i++) { | ||
108 | + uint32_t t = fn(&d); | ||
109 | |||
110 | - for (i = 0; i < 4; i++) { | ||
111 | - uint32_t t; | ||
112 | + t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | ||
113 | + + CR_ST_WORD(m, i); | ||
114 | |||
115 | - switch (op) { | ||
116 | - case 0: /* sha1c */ | ||
117 | - t = cho(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
118 | - break; | ||
119 | - case 1: /* sha1p */ | ||
120 | - t = par(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
121 | - break; | ||
122 | - case 2: /* sha1m */ | ||
123 | - t = maj(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
124 | - break; | ||
125 | - default: | ||
126 | - g_assert_not_reached(); | ||
127 | - } | ||
128 | - t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | ||
129 | - + CR_ST_WORD(m, i); | ||
130 | - | ||
131 | - CR_ST_WORD(n, 0) = CR_ST_WORD(d, 3); | ||
132 | - CR_ST_WORD(d, 3) = CR_ST_WORD(d, 2); | ||
133 | - CR_ST_WORD(d, 2) = ror32(CR_ST_WORD(d, 1), 2); | ||
134 | - CR_ST_WORD(d, 1) = CR_ST_WORD(d, 0); | ||
135 | - CR_ST_WORD(d, 0) = t; | ||
136 | - } | ||
137 | + CR_ST_WORD(n, 0) = CR_ST_WORD(d, 3); | ||
138 | + CR_ST_WORD(d, 3) = CR_ST_WORD(d, 2); | ||
139 | + CR_ST_WORD(d, 2) = ror32(CR_ST_WORD(d, 1), 2); | ||
140 | + CR_ST_WORD(d, 1) = CR_ST_WORD(d, 0); | ||
141 | + CR_ST_WORD(d, 0) = t; | ||
142 | } | ||
143 | rd[0] = d.l[0]; | ||
144 | rd[1] = d.l[1]; | ||
145 | + | 102 | + |
146 | + clear_tail_16(rd, desc); | 103 | static const TypeInfo imx7_gpt_info = { |
147 | +} | 104 | .name = TYPE_IMX7_GPT, |
148 | + | 105 | .parent = TYPE_IMX25_GPT, |
149 | +static uint32_t do_sha1c(union CRYPTO_STATE *d) | 106 | @@ -XXX,XX +XXX,XX @@ static void imx_gpt_register_types(void) |
150 | +{ | 107 | type_register_static(&imx25_gpt_info); |
151 | + return cho(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | 108 | type_register_static(&imx31_gpt_info); |
152 | +} | 109 | type_register_static(&imx6_gpt_info); |
153 | + | 110 | + type_register_static(&imx6ul_gpt_info); |
154 | +void HELPER(crypto_sha1c)(void *vd, void *vn, void *vm, uint32_t desc) | 111 | type_register_static(&imx7_gpt_info); |
155 | +{ | ||
156 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1c); | ||
157 | +} | ||
158 | + | ||
159 | +static uint32_t do_sha1p(union CRYPTO_STATE *d) | ||
160 | +{ | ||
161 | + return par(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
162 | +} | ||
163 | + | ||
164 | +void HELPER(crypto_sha1p)(void *vd, void *vn, void *vm, uint32_t desc) | ||
165 | +{ | ||
166 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1p); | ||
167 | +} | ||
168 | + | ||
169 | +static uint32_t do_sha1m(union CRYPTO_STATE *d) | ||
170 | +{ | ||
171 | + return maj(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
172 | +} | ||
173 | + | ||
174 | +void HELPER(crypto_sha1m)(void *vd, void *vn, void *vm, uint32_t desc) | ||
175 | +{ | ||
176 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1m); | ||
177 | } | 112 | } |
178 | 113 | ||
179 | void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | ||
180 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | --- a/target/arm/translate-a64.c | ||
183 | +++ b/target/arm/translate-a64.c | ||
184 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
185 | |||
186 | switch (opcode) { | ||
187 | case 0: /* SHA1C */ | ||
188 | + genfn = gen_helper_crypto_sha1c; | ||
189 | + feature = dc_isar_feature(aa64_sha1, s); | ||
190 | + break; | ||
191 | case 1: /* SHA1P */ | ||
192 | + genfn = gen_helper_crypto_sha1p; | ||
193 | + feature = dc_isar_feature(aa64_sha1, s); | ||
194 | + break; | ||
195 | case 2: /* SHA1M */ | ||
196 | + genfn = gen_helper_crypto_sha1m; | ||
197 | + feature = dc_isar_feature(aa64_sha1, s); | ||
198 | + break; | ||
199 | case 3: /* SHA1SU0 */ | ||
200 | - genfn = NULL; | ||
201 | + genfn = gen_helper_crypto_sha1su0; | ||
202 | feature = dc_isar_feature(aa64_sha1, s); | ||
203 | break; | ||
204 | case 4: /* SHA256H */ | ||
205 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
206 | if (!fp_access_check(s)) { | ||
207 | return; | ||
208 | } | ||
209 | - | ||
210 | - if (genfn) { | ||
211 | - gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
212 | - } else { | ||
213 | - TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | ||
214 | - TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
215 | - TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
216 | - TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
217 | - | ||
218 | - gen_helper_crypto_sha1_3reg(tcg_rd_ptr, tcg_rn_ptr, | ||
219 | - tcg_rm_ptr, tcg_opcode); | ||
220 | - | ||
221 | - tcg_temp_free_i32(tcg_opcode); | ||
222 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
223 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
224 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
225 | - } | ||
226 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
227 | } | ||
228 | |||
229 | /* Crypto two-reg SHA | ||
230 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
231 | index XXXXXXX..XXXXXXX 100644 | ||
232 | --- a/target/arm/translate-neon.inc.c | ||
233 | +++ b/target/arm/translate-neon.inc.c | ||
234 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | ||
235 | DO_VQRDMLAH(VQRDMLAH, gen_gvec_sqrdmlah_qc) | ||
236 | DO_VQRDMLAH(VQRDMLSH, gen_gvec_sqrdmlsh_qc) | ||
237 | |||
238 | -static bool trans_SHA1_3s(DisasContext *s, arg_SHA1_3s *a) | ||
239 | -{ | ||
240 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
241 | - TCGv_i32 tmp; | ||
242 | - | ||
243 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
244 | - !dc_isar_feature(aa32_sha1, s)) { | ||
245 | - return false; | ||
246 | +#define DO_SHA1(NAME, FUNC) \ | ||
247 | + WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
248 | + static bool trans_##NAME##_3s(DisasContext *s, arg_3same *a) \ | ||
249 | + { \ | ||
250 | + if (!dc_isar_feature(aa32_sha1, s)) { \ | ||
251 | + return false; \ | ||
252 | + } \ | ||
253 | + return do_3same(s, a, gen_##NAME##_3s); \ | ||
254 | } | ||
255 | |||
256 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
257 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
258 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
259 | - return false; | ||
260 | - } | ||
261 | - | ||
262 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
263 | - return false; | ||
264 | - } | ||
265 | - | ||
266 | - if (!vfp_access_check(s)) { | ||
267 | - return true; | ||
268 | - } | ||
269 | - | ||
270 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
271 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
272 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
273 | - tmp = tcg_const_i32(a->optype); | ||
274 | - gen_helper_crypto_sha1_3reg(ptr1, ptr2, ptr3, tmp); | ||
275 | - tcg_temp_free_i32(tmp); | ||
276 | - tcg_temp_free_ptr(ptr1); | ||
277 | - tcg_temp_free_ptr(ptr2); | ||
278 | - tcg_temp_free_ptr(ptr3); | ||
279 | - | ||
280 | - return true; | ||
281 | -} | ||
282 | +DO_SHA1(SHA1C, gen_helper_crypto_sha1c) | ||
283 | +DO_SHA1(SHA1P, gen_helper_crypto_sha1p) | ||
284 | +DO_SHA1(SHA1M, gen_helper_crypto_sha1m) | ||
285 | +DO_SHA1(SHA1SU0, gen_helper_crypto_sha1su0) | ||
286 | |||
287 | #define DO_SHA2(NAME, FUNC) \ | ||
288 | WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
289 | -- | 114 | -- |
290 | 2.20.1 | 115 | 2.25.1 |
291 | |||
292 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> |
---|---|---|---|
2 | 2 | ||
3 | Import the dwc-hsotg (dwc2) register definitions file from the | 3 | IRQs were not associated to the various GPIO devices inside i.MX7D. |
4 | Linux kernel. This is a copy of drivers/usb/dwc2/hw.h from the | 4 | This patch brings the i.MX7D on par with i.MX6. |
5 | mainline Linux kernel, the only changes being to the header, and | ||
6 | two instances of 'u32' changed to 'uint32_t' to allow it to | ||
7 | compile. Checkpatch throws a boatload of errors due to the tab | ||
8 | indentation, but I would rather import it as-is than reformat it. | ||
9 | 5 | ||
10 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> |
11 | Message-id: 20200520235349.21215-3-pauldzim@gmail.com | 7 | Message-id: 20221226101418.415170-1-jcd@tribudubois.net |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | include/hw/usb/dwc2-regs.h | 899 +++++++++++++++++++++++++++++++++++++ | 11 | include/hw/arm/fsl-imx7.h | 15 +++++++++++++++ |
16 | 1 file changed, 899 insertions(+) | 12 | hw/arm/fsl-imx7.c | 31 ++++++++++++++++++++++++++++++- |
17 | create mode 100644 include/hw/usb/dwc2-regs.h | 13 | 2 files changed, 45 insertions(+), 1 deletion(-) |
18 | 14 | ||
19 | diff --git a/include/hw/usb/dwc2-regs.h b/include/hw/usb/dwc2-regs.h | 15 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
20 | new file mode 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | index XXXXXXX..XXXXXXX | 17 | --- a/include/hw/arm/fsl-imx7.h |
22 | --- /dev/null | 18 | +++ b/include/hw/arm/fsl-imx7.h |
23 | +++ b/include/hw/usb/dwc2-regs.h | 19 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
24 | @@ -XXX,XX +XXX,XX @@ | 20 | FSL_IMX7_GPT3_IRQ = 53, |
25 | +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ | 21 | FSL_IMX7_GPT4_IRQ = 52, |
26 | +/* | 22 | |
27 | + * Imported from the Linux kernel file drivers/usb/dwc2/hw.h, commit | 23 | + FSL_IMX7_GPIO1_LOW_IRQ = 64, |
28 | + * a89bae709b3492b478480a2c9734e7e9393b279c ("usb: dwc2: Move | 24 | + FSL_IMX7_GPIO1_HIGH_IRQ = 65, |
29 | + * UTMI_PHY_DATA defines closer") | 25 | + FSL_IMX7_GPIO2_LOW_IRQ = 66, |
30 | + * | 26 | + FSL_IMX7_GPIO2_HIGH_IRQ = 67, |
31 | + * hw.h - DesignWare HS OTG Controller hardware definitions | 27 | + FSL_IMX7_GPIO3_LOW_IRQ = 68, |
32 | + * | 28 | + FSL_IMX7_GPIO3_HIGH_IRQ = 69, |
33 | + * Copyright 2004-2013 Synopsys, Inc. | 29 | + FSL_IMX7_GPIO4_LOW_IRQ = 70, |
34 | + * | 30 | + FSL_IMX7_GPIO4_HIGH_IRQ = 71, |
35 | + * Redistribution and use in source and binary forms, with or without | 31 | + FSL_IMX7_GPIO5_LOW_IRQ = 72, |
36 | + * modification, are permitted provided that the following conditions | 32 | + FSL_IMX7_GPIO5_HIGH_IRQ = 73, |
37 | + * are met: | 33 | + FSL_IMX7_GPIO6_LOW_IRQ = 74, |
38 | + * 1. Redistributions of source code must retain the above copyright | 34 | + FSL_IMX7_GPIO6_HIGH_IRQ = 75, |
39 | + * notice, this list of conditions, and the following disclaimer, | 35 | + FSL_IMX7_GPIO7_LOW_IRQ = 76, |
40 | + * without modification. | 36 | + FSL_IMX7_GPIO7_HIGH_IRQ = 77, |
41 | + * 2. Redistributions in binary form must reproduce the above copyright | ||
42 | + * notice, this list of conditions and the following disclaimer in the | ||
43 | + * documentation and/or other materials provided with the distribution. | ||
44 | + * 3. The names of the above-listed copyright holders may not be used | ||
45 | + * to endorse or promote products derived from this software without | ||
46 | + * specific prior written permission. | ||
47 | + * | ||
48 | + * ALTERNATIVELY, this software may be distributed under the terms of the | ||
49 | + * GNU General Public License ("GPL") as published by the Free Software | ||
50 | + * Foundation; either version 2 of the License, or (at your option) any | ||
51 | + * later version. | ||
52 | + * | ||
53 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
54 | + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
55 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
56 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
57 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
58 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
59 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
60 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
61 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
62 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
63 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
64 | + */ | ||
65 | + | 37 | + |
66 | +#ifndef __DWC2_HW_H__ | 38 | FSL_IMX7_WDOG1_IRQ = 78, |
67 | +#define __DWC2_HW_H__ | 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 | + }; | ||
68 | + | 58 | + |
69 | +#define HSOTG_REG(x) (x) | 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 | + }; | ||
70 | + | 68 | + |
71 | +#define GOTGCTL HSOTG_REG(0x000) | 69 | sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &error_abort); |
72 | +#define GOTGCTL_CHIRPEN BIT(27) | 70 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, FSL_IMX7_GPIOn_ADDR[i]); |
73 | +#define GOTGCTL_MULT_VALID_BC_MASK (0x1f << 22) | 71 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, |
74 | +#define GOTGCTL_MULT_VALID_BC_SHIFT 22 | 72 | + FSL_IMX7_GPIOn_ADDR[i]); |
75 | +#define GOTGCTL_OTGVER BIT(20) | ||
76 | +#define GOTGCTL_BSESVLD BIT(19) | ||
77 | +#define GOTGCTL_ASESVLD BIT(18) | ||
78 | +#define GOTGCTL_DBNC_SHORT BIT(17) | ||
79 | +#define GOTGCTL_CONID_B BIT(16) | ||
80 | +#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) | ||
81 | +#define GOTGCTL_DEVHNPEN BIT(11) | ||
82 | +#define GOTGCTL_HSTSETHNPEN BIT(10) | ||
83 | +#define GOTGCTL_HNPREQ BIT(9) | ||
84 | +#define GOTGCTL_HSTNEGSCS BIT(8) | ||
85 | +#define GOTGCTL_SESREQ BIT(1) | ||
86 | +#define GOTGCTL_SESREQSCS BIT(0) | ||
87 | + | 73 | + |
88 | +#define GOTGINT HSOTG_REG(0x004) | 74 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, |
89 | +#define GOTGINT_DBNCE_DONE BIT(19) | 75 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
90 | +#define GOTGINT_A_DEV_TOUT_CHG BIT(18) | 76 | + FSL_IMX7_GPIOn_LOW_IRQ[i])); |
91 | +#define GOTGINT_HST_NEG_DET BIT(17) | ||
92 | +#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) | ||
93 | +#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) | ||
94 | +#define GOTGINT_SES_END_DET BIT(2) | ||
95 | + | 77 | + |
96 | +#define GAHBCFG HSOTG_REG(0x008) | 78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1, |
97 | +#define GAHBCFG_AHB_SINGLE BIT(23) | 79 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
98 | +#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) | 80 | + FSL_IMX7_GPIOn_HIGH_IRQ[i])); |
99 | +#define GAHBCFG_REM_MEM_SUPP BIT(21) | 81 | } |
100 | +#define GAHBCFG_P_TXF_EMP_LVL BIT(8) | 82 | |
101 | +#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) | 83 | /* |
102 | +#define GAHBCFG_DMA_EN BIT(5) | ||
103 | +#define GAHBCFG_HBSTLEN_MASK (0xf << 1) | ||
104 | +#define GAHBCFG_HBSTLEN_SHIFT 1 | ||
105 | +#define GAHBCFG_HBSTLEN_SINGLE 0 | ||
106 | +#define GAHBCFG_HBSTLEN_INCR 1 | ||
107 | +#define GAHBCFG_HBSTLEN_INCR4 3 | ||
108 | +#define GAHBCFG_HBSTLEN_INCR8 5 | ||
109 | +#define GAHBCFG_HBSTLEN_INCR16 7 | ||
110 | +#define GAHBCFG_GLBL_INTR_EN BIT(0) | ||
111 | +#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ | ||
112 | + GAHBCFG_NP_TXF_EMP_LVL | \ | ||
113 | + GAHBCFG_DMA_EN | \ | ||
114 | + GAHBCFG_GLBL_INTR_EN) | ||
115 | + | ||
116 | +#define GUSBCFG HSOTG_REG(0x00C) | ||
117 | +#define GUSBCFG_FORCEDEVMODE BIT(30) | ||
118 | +#define GUSBCFG_FORCEHOSTMODE BIT(29) | ||
119 | +#define GUSBCFG_TXENDDELAY BIT(28) | ||
120 | +#define GUSBCFG_ICTRAFFICPULLREMOVE BIT(27) | ||
121 | +#define GUSBCFG_ICUSBCAP BIT(26) | ||
122 | +#define GUSBCFG_ULPI_INT_PROT_DIS BIT(25) | ||
123 | +#define GUSBCFG_INDICATORPASSTHROUGH BIT(24) | ||
124 | +#define GUSBCFG_INDICATORCOMPLEMENT BIT(23) | ||
125 | +#define GUSBCFG_TERMSELDLPULSE BIT(22) | ||
126 | +#define GUSBCFG_ULPI_INT_VBUS_IND BIT(21) | ||
127 | +#define GUSBCFG_ULPI_EXT_VBUS_DRV BIT(20) | ||
128 | +#define GUSBCFG_ULPI_CLK_SUSP_M BIT(19) | ||
129 | +#define GUSBCFG_ULPI_AUTO_RES BIT(18) | ||
130 | +#define GUSBCFG_ULPI_FS_LS BIT(17) | ||
131 | +#define GUSBCFG_OTG_UTMI_FS_SEL BIT(16) | ||
132 | +#define GUSBCFG_PHY_LP_CLK_SEL BIT(15) | ||
133 | +#define GUSBCFG_USBTRDTIM_MASK (0xf << 10) | ||
134 | +#define GUSBCFG_USBTRDTIM_SHIFT 10 | ||
135 | +#define GUSBCFG_HNPCAP BIT(9) | ||
136 | +#define GUSBCFG_SRPCAP BIT(8) | ||
137 | +#define GUSBCFG_DDRSEL BIT(7) | ||
138 | +#define GUSBCFG_PHYSEL BIT(6) | ||
139 | +#define GUSBCFG_FSINTF BIT(5) | ||
140 | +#define GUSBCFG_ULPI_UTMI_SEL BIT(4) | ||
141 | +#define GUSBCFG_PHYIF16 BIT(3) | ||
142 | +#define GUSBCFG_PHYIF8 (0 << 3) | ||
143 | +#define GUSBCFG_TOUTCAL_MASK (0x7 << 0) | ||
144 | +#define GUSBCFG_TOUTCAL_SHIFT 0 | ||
145 | +#define GUSBCFG_TOUTCAL_LIMIT 0x7 | ||
146 | +#define GUSBCFG_TOUTCAL(_x) ((_x) << 0) | ||
147 | + | ||
148 | +#define GRSTCTL HSOTG_REG(0x010) | ||
149 | +#define GRSTCTL_AHBIDLE BIT(31) | ||
150 | +#define GRSTCTL_DMAREQ BIT(30) | ||
151 | +#define GRSTCTL_TXFNUM_MASK (0x1f << 6) | ||
152 | +#define GRSTCTL_TXFNUM_SHIFT 6 | ||
153 | +#define GRSTCTL_TXFNUM_LIMIT 0x1f | ||
154 | +#define GRSTCTL_TXFNUM(_x) ((_x) << 6) | ||
155 | +#define GRSTCTL_TXFFLSH BIT(5) | ||
156 | +#define GRSTCTL_RXFFLSH BIT(4) | ||
157 | +#define GRSTCTL_IN_TKNQ_FLSH BIT(3) | ||
158 | +#define GRSTCTL_FRMCNTRRST BIT(2) | ||
159 | +#define GRSTCTL_HSFTRST BIT(1) | ||
160 | +#define GRSTCTL_CSFTRST BIT(0) | ||
161 | + | ||
162 | +#define GINTSTS HSOTG_REG(0x014) | ||
163 | +#define GINTMSK HSOTG_REG(0x018) | ||
164 | +#define GINTSTS_WKUPINT BIT(31) | ||
165 | +#define GINTSTS_SESSREQINT BIT(30) | ||
166 | +#define GINTSTS_DISCONNINT BIT(29) | ||
167 | +#define GINTSTS_CONIDSTSCHNG BIT(28) | ||
168 | +#define GINTSTS_LPMTRANRCVD BIT(27) | ||
169 | +#define GINTSTS_PTXFEMP BIT(26) | ||
170 | +#define GINTSTS_HCHINT BIT(25) | ||
171 | +#define GINTSTS_PRTINT BIT(24) | ||
172 | +#define GINTSTS_RESETDET BIT(23) | ||
173 | +#define GINTSTS_FET_SUSP BIT(22) | ||
174 | +#define GINTSTS_INCOMPL_IP BIT(21) | ||
175 | +#define GINTSTS_INCOMPL_SOOUT BIT(21) | ||
176 | +#define GINTSTS_INCOMPL_SOIN BIT(20) | ||
177 | +#define GINTSTS_OEPINT BIT(19) | ||
178 | +#define GINTSTS_IEPINT BIT(18) | ||
179 | +#define GINTSTS_EPMIS BIT(17) | ||
180 | +#define GINTSTS_RESTOREDONE BIT(16) | ||
181 | +#define GINTSTS_EOPF BIT(15) | ||
182 | +#define GINTSTS_ISOUTDROP BIT(14) | ||
183 | +#define GINTSTS_ENUMDONE BIT(13) | ||
184 | +#define GINTSTS_USBRST BIT(12) | ||
185 | +#define GINTSTS_USBSUSP BIT(11) | ||
186 | +#define GINTSTS_ERLYSUSP BIT(10) | ||
187 | +#define GINTSTS_I2CINT BIT(9) | ||
188 | +#define GINTSTS_ULPI_CK_INT BIT(8) | ||
189 | +#define GINTSTS_GOUTNAKEFF BIT(7) | ||
190 | +#define GINTSTS_GINNAKEFF BIT(6) | ||
191 | +#define GINTSTS_NPTXFEMP BIT(5) | ||
192 | +#define GINTSTS_RXFLVL BIT(4) | ||
193 | +#define GINTSTS_SOF BIT(3) | ||
194 | +#define GINTSTS_OTGINT BIT(2) | ||
195 | +#define GINTSTS_MODEMIS BIT(1) | ||
196 | +#define GINTSTS_CURMODE_HOST BIT(0) | ||
197 | + | ||
198 | +#define GRXSTSR HSOTG_REG(0x01C) | ||
199 | +#define GRXSTSP HSOTG_REG(0x020) | ||
200 | +#define GRXSTS_FN_MASK (0x7f << 25) | ||
201 | +#define GRXSTS_FN_SHIFT 25 | ||
202 | +#define GRXSTS_PKTSTS_MASK (0xf << 17) | ||
203 | +#define GRXSTS_PKTSTS_SHIFT 17 | ||
204 | +#define GRXSTS_PKTSTS_GLOBALOUTNAK 1 | ||
205 | +#define GRXSTS_PKTSTS_OUTRX 2 | ||
206 | +#define GRXSTS_PKTSTS_HCHIN 2 | ||
207 | +#define GRXSTS_PKTSTS_OUTDONE 3 | ||
208 | +#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3 | ||
209 | +#define GRXSTS_PKTSTS_SETUPDONE 4 | ||
210 | +#define GRXSTS_PKTSTS_DATATOGGLEERR 5 | ||
211 | +#define GRXSTS_PKTSTS_SETUPRX 6 | ||
212 | +#define GRXSTS_PKTSTS_HCHHALTED 7 | ||
213 | +#define GRXSTS_HCHNUM_MASK (0xf << 0) | ||
214 | +#define GRXSTS_HCHNUM_SHIFT 0 | ||
215 | +#define GRXSTS_DPID_MASK (0x3 << 15) | ||
216 | +#define GRXSTS_DPID_SHIFT 15 | ||
217 | +#define GRXSTS_BYTECNT_MASK (0x7ff << 4) | ||
218 | +#define GRXSTS_BYTECNT_SHIFT 4 | ||
219 | +#define GRXSTS_EPNUM_MASK (0xf << 0) | ||
220 | +#define GRXSTS_EPNUM_SHIFT 0 | ||
221 | + | ||
222 | +#define GRXFSIZ HSOTG_REG(0x024) | ||
223 | +#define GRXFSIZ_DEPTH_MASK (0xffff << 0) | ||
224 | +#define GRXFSIZ_DEPTH_SHIFT 0 | ||
225 | + | ||
226 | +#define GNPTXFSIZ HSOTG_REG(0x028) | ||
227 | +/* Use FIFOSIZE_* constants to access this register */ | ||
228 | + | ||
229 | +#define GNPTXSTS HSOTG_REG(0x02C) | ||
230 | +#define GNPTXSTS_NP_TXQ_TOP_MASK (0x7f << 24) | ||
231 | +#define GNPTXSTS_NP_TXQ_TOP_SHIFT 24 | ||
232 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_MASK (0xff << 16) | ||
233 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_SHIFT 16 | ||
234 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_GET(_v) (((_v) >> 16) & 0xff) | ||
235 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_MASK (0xffff << 0) | ||
236 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_SHIFT 0 | ||
237 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_GET(_v) (((_v) >> 0) & 0xffff) | ||
238 | + | ||
239 | +#define GI2CCTL HSOTG_REG(0x0030) | ||
240 | +#define GI2CCTL_BSYDNE BIT(31) | ||
241 | +#define GI2CCTL_RW BIT(30) | ||
242 | +#define GI2CCTL_I2CDATSE0 BIT(28) | ||
243 | +#define GI2CCTL_I2CDEVADDR_MASK (0x3 << 26) | ||
244 | +#define GI2CCTL_I2CDEVADDR_SHIFT 26 | ||
245 | +#define GI2CCTL_I2CSUSPCTL BIT(25) | ||
246 | +#define GI2CCTL_ACK BIT(24) | ||
247 | +#define GI2CCTL_I2CEN BIT(23) | ||
248 | +#define GI2CCTL_ADDR_MASK (0x7f << 16) | ||
249 | +#define GI2CCTL_ADDR_SHIFT 16 | ||
250 | +#define GI2CCTL_REGADDR_MASK (0xff << 8) | ||
251 | +#define GI2CCTL_REGADDR_SHIFT 8 | ||
252 | +#define GI2CCTL_RWDATA_MASK (0xff << 0) | ||
253 | +#define GI2CCTL_RWDATA_SHIFT 0 | ||
254 | + | ||
255 | +#define GPVNDCTL HSOTG_REG(0x0034) | ||
256 | +#define GGPIO HSOTG_REG(0x0038) | ||
257 | +#define GGPIO_STM32_OTG_GCCFG_PWRDWN BIT(16) | ||
258 | + | ||
259 | +#define GUID HSOTG_REG(0x003c) | ||
260 | +#define GSNPSID HSOTG_REG(0x0040) | ||
261 | +#define GHWCFG1 HSOTG_REG(0x0044) | ||
262 | +#define GSNPSID_ID_MASK GENMASK(31, 16) | ||
263 | + | ||
264 | +#define GHWCFG2 HSOTG_REG(0x0048) | ||
265 | +#define GHWCFG2_OTG_ENABLE_IC_USB BIT(31) | ||
266 | +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK (0x1f << 26) | ||
267 | +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT 26 | ||
268 | +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK (0x3 << 24) | ||
269 | +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT 24 | ||
270 | +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK (0x3 << 22) | ||
271 | +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT 22 | ||
272 | +#define GHWCFG2_MULTI_PROC_INT BIT(20) | ||
273 | +#define GHWCFG2_DYNAMIC_FIFO BIT(19) | ||
274 | +#define GHWCFG2_PERIO_EP_SUPPORTED BIT(18) | ||
275 | +#define GHWCFG2_NUM_HOST_CHAN_MASK (0xf << 14) | ||
276 | +#define GHWCFG2_NUM_HOST_CHAN_SHIFT 14 | ||
277 | +#define GHWCFG2_NUM_DEV_EP_MASK (0xf << 10) | ||
278 | +#define GHWCFG2_NUM_DEV_EP_SHIFT 10 | ||
279 | +#define GHWCFG2_FS_PHY_TYPE_MASK (0x3 << 8) | ||
280 | +#define GHWCFG2_FS_PHY_TYPE_SHIFT 8 | ||
281 | +#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 | ||
282 | +#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 | ||
283 | +#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 | ||
284 | +#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 | ||
285 | +#define GHWCFG2_HS_PHY_TYPE_MASK (0x3 << 6) | ||
286 | +#define GHWCFG2_HS_PHY_TYPE_SHIFT 6 | ||
287 | +#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 | ||
288 | +#define GHWCFG2_HS_PHY_TYPE_UTMI 1 | ||
289 | +#define GHWCFG2_HS_PHY_TYPE_ULPI 2 | ||
290 | +#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 | ||
291 | +#define GHWCFG2_POINT2POINT BIT(5) | ||
292 | +#define GHWCFG2_ARCHITECTURE_MASK (0x3 << 3) | ||
293 | +#define GHWCFG2_ARCHITECTURE_SHIFT 3 | ||
294 | +#define GHWCFG2_SLAVE_ONLY_ARCH 0 | ||
295 | +#define GHWCFG2_EXT_DMA_ARCH 1 | ||
296 | +#define GHWCFG2_INT_DMA_ARCH 2 | ||
297 | +#define GHWCFG2_OP_MODE_MASK (0x7 << 0) | ||
298 | +#define GHWCFG2_OP_MODE_SHIFT 0 | ||
299 | +#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 | ||
300 | +#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 | ||
301 | +#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 | ||
302 | +#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 | ||
303 | +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 | ||
304 | +#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 | ||
305 | +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 | ||
306 | +#define GHWCFG2_OP_MODE_UNDEFINED 7 | ||
307 | + | ||
308 | +#define GHWCFG3 HSOTG_REG(0x004c) | ||
309 | +#define GHWCFG3_DFIFO_DEPTH_MASK (0xffff << 16) | ||
310 | +#define GHWCFG3_DFIFO_DEPTH_SHIFT 16 | ||
311 | +#define GHWCFG3_OTG_LPM_EN BIT(15) | ||
312 | +#define GHWCFG3_BC_SUPPORT BIT(14) | ||
313 | +#define GHWCFG3_OTG_ENABLE_HSIC BIT(13) | ||
314 | +#define GHWCFG3_ADP_SUPP BIT(12) | ||
315 | +#define GHWCFG3_SYNCH_RESET_TYPE BIT(11) | ||
316 | +#define GHWCFG3_OPTIONAL_FEATURES BIT(10) | ||
317 | +#define GHWCFG3_VENDOR_CTRL_IF BIT(9) | ||
318 | +#define GHWCFG3_I2C BIT(8) | ||
319 | +#define GHWCFG3_OTG_FUNC BIT(7) | ||
320 | +#define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK (0x7 << 4) | ||
321 | +#define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT 4 | ||
322 | +#define GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK (0xf << 0) | ||
323 | +#define GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT 0 | ||
324 | + | ||
325 | +#define GHWCFG4 HSOTG_REG(0x0050) | ||
326 | +#define GHWCFG4_DESC_DMA_DYN BIT(31) | ||
327 | +#define GHWCFG4_DESC_DMA BIT(30) | ||
328 | +#define GHWCFG4_NUM_IN_EPS_MASK (0xf << 26) | ||
329 | +#define GHWCFG4_NUM_IN_EPS_SHIFT 26 | ||
330 | +#define GHWCFG4_DED_FIFO_EN BIT(25) | ||
331 | +#define GHWCFG4_DED_FIFO_SHIFT 25 | ||
332 | +#define GHWCFG4_SESSION_END_FILT_EN BIT(24) | ||
333 | +#define GHWCFG4_B_VALID_FILT_EN BIT(23) | ||
334 | +#define GHWCFG4_A_VALID_FILT_EN BIT(22) | ||
335 | +#define GHWCFG4_VBUS_VALID_FILT_EN BIT(21) | ||
336 | +#define GHWCFG4_IDDIG_FILT_EN BIT(20) | ||
337 | +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK (0xf << 16) | ||
338 | +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16 | ||
339 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14) | ||
340 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14 | ||
341 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 | ||
342 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 | ||
343 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 | ||
344 | +#define GHWCFG4_ACG_SUPPORTED BIT(12) | ||
345 | +#define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) | ||
346 | +#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) | ||
347 | +#define GHWCFG4_XHIBER BIT(7) | ||
348 | +#define GHWCFG4_HIBER BIT(6) | ||
349 | +#define GHWCFG4_MIN_AHB_FREQ BIT(5) | ||
350 | +#define GHWCFG4_POWER_OPTIMIZ BIT(4) | ||
351 | +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK (0xf << 0) | ||
352 | +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT 0 | ||
353 | + | ||
354 | +#define GLPMCFG HSOTG_REG(0x0054) | ||
355 | +#define GLPMCFG_INVSELHSIC BIT(31) | ||
356 | +#define GLPMCFG_HSICCON BIT(30) | ||
357 | +#define GLPMCFG_RSTRSLPSTS BIT(29) | ||
358 | +#define GLPMCFG_ENBESL BIT(28) | ||
359 | +#define GLPMCFG_LPM_RETRYCNT_STS_MASK (0x7 << 25) | ||
360 | +#define GLPMCFG_LPM_RETRYCNT_STS_SHIFT 25 | ||
361 | +#define GLPMCFG_SNDLPM BIT(24) | ||
362 | +#define GLPMCFG_RETRY_CNT_MASK (0x7 << 21) | ||
363 | +#define GLPMCFG_RETRY_CNT_SHIFT 21 | ||
364 | +#define GLPMCFG_LPM_REJECT_CTRL_CONTROL BIT(21) | ||
365 | +#define GLPMCFG_LPM_ACCEPT_CTRL_ISOC BIT(22) | ||
366 | +#define GLPMCFG_LPM_CHNL_INDX_MASK (0xf << 17) | ||
367 | +#define GLPMCFG_LPM_CHNL_INDX_SHIFT 17 | ||
368 | +#define GLPMCFG_L1RESUMEOK BIT(16) | ||
369 | +#define GLPMCFG_SLPSTS BIT(15) | ||
370 | +#define GLPMCFG_COREL1RES_MASK (0x3 << 13) | ||
371 | +#define GLPMCFG_COREL1RES_SHIFT 13 | ||
372 | +#define GLPMCFG_HIRD_THRES_MASK (0x1f << 8) | ||
373 | +#define GLPMCFG_HIRD_THRES_SHIFT 8 | ||
374 | +#define GLPMCFG_HIRD_THRES_EN (0x10 << 8) | ||
375 | +#define GLPMCFG_ENBLSLPM BIT(7) | ||
376 | +#define GLPMCFG_BREMOTEWAKE BIT(6) | ||
377 | +#define GLPMCFG_HIRD_MASK (0xf << 2) | ||
378 | +#define GLPMCFG_HIRD_SHIFT 2 | ||
379 | +#define GLPMCFG_APPL1RES BIT(1) | ||
380 | +#define GLPMCFG_LPMCAP BIT(0) | ||
381 | + | ||
382 | +#define GPWRDN HSOTG_REG(0x0058) | ||
383 | +#define GPWRDN_MULT_VAL_ID_BC_MASK (0x1f << 24) | ||
384 | +#define GPWRDN_MULT_VAL_ID_BC_SHIFT 24 | ||
385 | +#define GPWRDN_ADP_INT BIT(23) | ||
386 | +#define GPWRDN_BSESSVLD BIT(22) | ||
387 | +#define GPWRDN_IDSTS BIT(21) | ||
388 | +#define GPWRDN_LINESTATE_MASK (0x3 << 19) | ||
389 | +#define GPWRDN_LINESTATE_SHIFT 19 | ||
390 | +#define GPWRDN_STS_CHGINT_MSK BIT(18) | ||
391 | +#define GPWRDN_STS_CHGINT BIT(17) | ||
392 | +#define GPWRDN_SRP_DET_MSK BIT(16) | ||
393 | +#define GPWRDN_SRP_DET BIT(15) | ||
394 | +#define GPWRDN_CONNECT_DET_MSK BIT(14) | ||
395 | +#define GPWRDN_CONNECT_DET BIT(13) | ||
396 | +#define GPWRDN_DISCONN_DET_MSK BIT(12) | ||
397 | +#define GPWRDN_DISCONN_DET BIT(11) | ||
398 | +#define GPWRDN_RST_DET_MSK BIT(10) | ||
399 | +#define GPWRDN_RST_DET BIT(9) | ||
400 | +#define GPWRDN_LNSTSCHG_MSK BIT(8) | ||
401 | +#define GPWRDN_LNSTSCHG BIT(7) | ||
402 | +#define GPWRDN_DIS_VBUS BIT(6) | ||
403 | +#define GPWRDN_PWRDNSWTCH BIT(5) | ||
404 | +#define GPWRDN_PWRDNRSTN BIT(4) | ||
405 | +#define GPWRDN_PWRDNCLMP BIT(3) | ||
406 | +#define GPWRDN_RESTORE BIT(2) | ||
407 | +#define GPWRDN_PMUACTV BIT(1) | ||
408 | +#define GPWRDN_PMUINTSEL BIT(0) | ||
409 | + | ||
410 | +#define GDFIFOCFG HSOTG_REG(0x005c) | ||
411 | +#define GDFIFOCFG_EPINFOBASE_MASK (0xffff << 16) | ||
412 | +#define GDFIFOCFG_EPINFOBASE_SHIFT 16 | ||
413 | +#define GDFIFOCFG_GDFIFOCFG_MASK (0xffff << 0) | ||
414 | +#define GDFIFOCFG_GDFIFOCFG_SHIFT 0 | ||
415 | + | ||
416 | +#define ADPCTL HSOTG_REG(0x0060) | ||
417 | +#define ADPCTL_AR_MASK (0x3 << 27) | ||
418 | +#define ADPCTL_AR_SHIFT 27 | ||
419 | +#define ADPCTL_ADP_TMOUT_INT_MSK BIT(26) | ||
420 | +#define ADPCTL_ADP_SNS_INT_MSK BIT(25) | ||
421 | +#define ADPCTL_ADP_PRB_INT_MSK BIT(24) | ||
422 | +#define ADPCTL_ADP_TMOUT_INT BIT(23) | ||
423 | +#define ADPCTL_ADP_SNS_INT BIT(22) | ||
424 | +#define ADPCTL_ADP_PRB_INT BIT(21) | ||
425 | +#define ADPCTL_ADPENA BIT(20) | ||
426 | +#define ADPCTL_ADPRES BIT(19) | ||
427 | +#define ADPCTL_ENASNS BIT(18) | ||
428 | +#define ADPCTL_ENAPRB BIT(17) | ||
429 | +#define ADPCTL_RTIM_MASK (0x7ff << 6) | ||
430 | +#define ADPCTL_RTIM_SHIFT 6 | ||
431 | +#define ADPCTL_PRB_PER_MASK (0x3 << 4) | ||
432 | +#define ADPCTL_PRB_PER_SHIFT 4 | ||
433 | +#define ADPCTL_PRB_DELTA_MASK (0x3 << 2) | ||
434 | +#define ADPCTL_PRB_DELTA_SHIFT 2 | ||
435 | +#define ADPCTL_PRB_DSCHRG_MASK (0x3 << 0) | ||
436 | +#define ADPCTL_PRB_DSCHRG_SHIFT 0 | ||
437 | + | ||
438 | +#define GREFCLK HSOTG_REG(0x0064) | ||
439 | +#define GREFCLK_REFCLKPER_MASK (0x1ffff << 15) | ||
440 | +#define GREFCLK_REFCLKPER_SHIFT 15 | ||
441 | +#define GREFCLK_REF_CLK_MODE BIT(14) | ||
442 | +#define GREFCLK_SOF_CNT_WKUP_ALERT_MASK (0x3ff) | ||
443 | +#define GREFCLK_SOF_CNT_WKUP_ALERT_SHIFT 0 | ||
444 | + | ||
445 | +#define GINTMSK2 HSOTG_REG(0x0068) | ||
446 | +#define GINTMSK2_WKUP_ALERT_INT_MSK BIT(0) | ||
447 | + | ||
448 | +#define GINTSTS2 HSOTG_REG(0x006c) | ||
449 | +#define GINTSTS2_WKUP_ALERT_INT BIT(0) | ||
450 | + | ||
451 | +#define HPTXFSIZ HSOTG_REG(0x100) | ||
452 | +/* Use FIFOSIZE_* constants to access this register */ | ||
453 | + | ||
454 | +#define DPTXFSIZN(_a) HSOTG_REG(0x104 + (((_a) - 1) * 4)) | ||
455 | +/* Use FIFOSIZE_* constants to access this register */ | ||
456 | + | ||
457 | +/* These apply to the GNPTXFSIZ, HPTXFSIZ and DPTXFSIZN registers */ | ||
458 | +#define FIFOSIZE_DEPTH_MASK (0xffff << 16) | ||
459 | +#define FIFOSIZE_DEPTH_SHIFT 16 | ||
460 | +#define FIFOSIZE_STARTADDR_MASK (0xffff << 0) | ||
461 | +#define FIFOSIZE_STARTADDR_SHIFT 0 | ||
462 | +#define FIFOSIZE_DEPTH_GET(_x) (((_x) >> 16) & 0xffff) | ||
463 | + | ||
464 | +/* Device mode registers */ | ||
465 | + | ||
466 | +#define DCFG HSOTG_REG(0x800) | ||
467 | +#define DCFG_DESCDMA_EN BIT(23) | ||
468 | +#define DCFG_EPMISCNT_MASK (0x1f << 18) | ||
469 | +#define DCFG_EPMISCNT_SHIFT 18 | ||
470 | +#define DCFG_EPMISCNT_LIMIT 0x1f | ||
471 | +#define DCFG_EPMISCNT(_x) ((_x) << 18) | ||
472 | +#define DCFG_IPG_ISOC_SUPPORDED BIT(17) | ||
473 | +#define DCFG_PERFRINT_MASK (0x3 << 11) | ||
474 | +#define DCFG_PERFRINT_SHIFT 11 | ||
475 | +#define DCFG_PERFRINT_LIMIT 0x3 | ||
476 | +#define DCFG_PERFRINT(_x) ((_x) << 11) | ||
477 | +#define DCFG_DEVADDR_MASK (0x7f << 4) | ||
478 | +#define DCFG_DEVADDR_SHIFT 4 | ||
479 | +#define DCFG_DEVADDR_LIMIT 0x7f | ||
480 | +#define DCFG_DEVADDR(_x) ((_x) << 4) | ||
481 | +#define DCFG_NZ_STS_OUT_HSHK BIT(2) | ||
482 | +#define DCFG_DEVSPD_MASK (0x3 << 0) | ||
483 | +#define DCFG_DEVSPD_SHIFT 0 | ||
484 | +#define DCFG_DEVSPD_HS 0 | ||
485 | +#define DCFG_DEVSPD_FS 1 | ||
486 | +#define DCFG_DEVSPD_LS 2 | ||
487 | +#define DCFG_DEVSPD_FS48 3 | ||
488 | + | ||
489 | +#define DCTL HSOTG_REG(0x804) | ||
490 | +#define DCTL_SERVICE_INTERVAL_SUPPORTED BIT(19) | ||
491 | +#define DCTL_PWRONPRGDONE BIT(11) | ||
492 | +#define DCTL_CGOUTNAK BIT(10) | ||
493 | +#define DCTL_SGOUTNAK BIT(9) | ||
494 | +#define DCTL_CGNPINNAK BIT(8) | ||
495 | +#define DCTL_SGNPINNAK BIT(7) | ||
496 | +#define DCTL_TSTCTL_MASK (0x7 << 4) | ||
497 | +#define DCTL_TSTCTL_SHIFT 4 | ||
498 | +#define DCTL_GOUTNAKSTS BIT(3) | ||
499 | +#define DCTL_GNPINNAKSTS BIT(2) | ||
500 | +#define DCTL_SFTDISCON BIT(1) | ||
501 | +#define DCTL_RMTWKUPSIG BIT(0) | ||
502 | + | ||
503 | +#define DSTS HSOTG_REG(0x808) | ||
504 | +#define DSTS_SOFFN_MASK (0x3fff << 8) | ||
505 | +#define DSTS_SOFFN_SHIFT 8 | ||
506 | +#define DSTS_SOFFN_LIMIT 0x3fff | ||
507 | +#define DSTS_SOFFN(_x) ((_x) << 8) | ||
508 | +#define DSTS_ERRATICERR BIT(3) | ||
509 | +#define DSTS_ENUMSPD_MASK (0x3 << 1) | ||
510 | +#define DSTS_ENUMSPD_SHIFT 1 | ||
511 | +#define DSTS_ENUMSPD_HS 0 | ||
512 | +#define DSTS_ENUMSPD_FS 1 | ||
513 | +#define DSTS_ENUMSPD_LS 2 | ||
514 | +#define DSTS_ENUMSPD_FS48 3 | ||
515 | +#define DSTS_SUSPSTS BIT(0) | ||
516 | + | ||
517 | +#define DIEPMSK HSOTG_REG(0x810) | ||
518 | +#define DIEPMSK_NAKMSK BIT(13) | ||
519 | +#define DIEPMSK_BNAININTRMSK BIT(9) | ||
520 | +#define DIEPMSK_TXFIFOUNDRNMSK BIT(8) | ||
521 | +#define DIEPMSK_TXFIFOEMPTY BIT(7) | ||
522 | +#define DIEPMSK_INEPNAKEFFMSK BIT(6) | ||
523 | +#define DIEPMSK_INTKNEPMISMSK BIT(5) | ||
524 | +#define DIEPMSK_INTKNTXFEMPMSK BIT(4) | ||
525 | +#define DIEPMSK_TIMEOUTMSK BIT(3) | ||
526 | +#define DIEPMSK_AHBERRMSK BIT(2) | ||
527 | +#define DIEPMSK_EPDISBLDMSK BIT(1) | ||
528 | +#define DIEPMSK_XFERCOMPLMSK BIT(0) | ||
529 | + | ||
530 | +#define DOEPMSK HSOTG_REG(0x814) | ||
531 | +#define DOEPMSK_BNAMSK BIT(9) | ||
532 | +#define DOEPMSK_BACK2BACKSETUP BIT(6) | ||
533 | +#define DOEPMSK_STSPHSERCVDMSK BIT(5) | ||
534 | +#define DOEPMSK_OUTTKNEPDISMSK BIT(4) | ||
535 | +#define DOEPMSK_SETUPMSK BIT(3) | ||
536 | +#define DOEPMSK_AHBERRMSK BIT(2) | ||
537 | +#define DOEPMSK_EPDISBLDMSK BIT(1) | ||
538 | +#define DOEPMSK_XFERCOMPLMSK BIT(0) | ||
539 | + | ||
540 | +#define DAINT HSOTG_REG(0x818) | ||
541 | +#define DAINTMSK HSOTG_REG(0x81C) | ||
542 | +#define DAINT_OUTEP_SHIFT 16 | ||
543 | +#define DAINT_OUTEP(_x) (1 << ((_x) + 16)) | ||
544 | +#define DAINT_INEP(_x) (1 << (_x)) | ||
545 | + | ||
546 | +#define DTKNQR1 HSOTG_REG(0x820) | ||
547 | +#define DTKNQR2 HSOTG_REG(0x824) | ||
548 | +#define DTKNQR3 HSOTG_REG(0x830) | ||
549 | +#define DTKNQR4 HSOTG_REG(0x834) | ||
550 | +#define DIEPEMPMSK HSOTG_REG(0x834) | ||
551 | + | ||
552 | +#define DVBUSDIS HSOTG_REG(0x828) | ||
553 | +#define DVBUSPULSE HSOTG_REG(0x82C) | ||
554 | + | ||
555 | +#define DIEPCTL0 HSOTG_REG(0x900) | ||
556 | +#define DIEPCTL(_a) HSOTG_REG(0x900 + ((_a) * 0x20)) | ||
557 | + | ||
558 | +#define DOEPCTL0 HSOTG_REG(0xB00) | ||
559 | +#define DOEPCTL(_a) HSOTG_REG(0xB00 + ((_a) * 0x20)) | ||
560 | + | ||
561 | +/* EP0 specialness: | ||
562 | + * bits[29..28] - reserved (no SetD0PID, SetD1PID) | ||
563 | + * bits[25..22] - should always be zero, this isn't a periodic endpoint | ||
564 | + * bits[10..0] - MPS setting different for EP0 | ||
565 | + */ | ||
566 | +#define D0EPCTL_MPS_MASK (0x3 << 0) | ||
567 | +#define D0EPCTL_MPS_SHIFT 0 | ||
568 | +#define D0EPCTL_MPS_64 0 | ||
569 | +#define D0EPCTL_MPS_32 1 | ||
570 | +#define D0EPCTL_MPS_16 2 | ||
571 | +#define D0EPCTL_MPS_8 3 | ||
572 | + | ||
573 | +#define DXEPCTL_EPENA BIT(31) | ||
574 | +#define DXEPCTL_EPDIS BIT(30) | ||
575 | +#define DXEPCTL_SETD1PID BIT(29) | ||
576 | +#define DXEPCTL_SETODDFR BIT(29) | ||
577 | +#define DXEPCTL_SETD0PID BIT(28) | ||
578 | +#define DXEPCTL_SETEVENFR BIT(28) | ||
579 | +#define DXEPCTL_SNAK BIT(27) | ||
580 | +#define DXEPCTL_CNAK BIT(26) | ||
581 | +#define DXEPCTL_TXFNUM_MASK (0xf << 22) | ||
582 | +#define DXEPCTL_TXFNUM_SHIFT 22 | ||
583 | +#define DXEPCTL_TXFNUM_LIMIT 0xf | ||
584 | +#define DXEPCTL_TXFNUM(_x) ((_x) << 22) | ||
585 | +#define DXEPCTL_STALL BIT(21) | ||
586 | +#define DXEPCTL_SNP BIT(20) | ||
587 | +#define DXEPCTL_EPTYPE_MASK (0x3 << 18) | ||
588 | +#define DXEPCTL_EPTYPE_CONTROL (0x0 << 18) | ||
589 | +#define DXEPCTL_EPTYPE_ISO (0x1 << 18) | ||
590 | +#define DXEPCTL_EPTYPE_BULK (0x2 << 18) | ||
591 | +#define DXEPCTL_EPTYPE_INTERRUPT (0x3 << 18) | ||
592 | + | ||
593 | +#define DXEPCTL_NAKSTS BIT(17) | ||
594 | +#define DXEPCTL_DPID BIT(16) | ||
595 | +#define DXEPCTL_EOFRNUM BIT(16) | ||
596 | +#define DXEPCTL_USBACTEP BIT(15) | ||
597 | +#define DXEPCTL_NEXTEP_MASK (0xf << 11) | ||
598 | +#define DXEPCTL_NEXTEP_SHIFT 11 | ||
599 | +#define DXEPCTL_NEXTEP_LIMIT 0xf | ||
600 | +#define DXEPCTL_NEXTEP(_x) ((_x) << 11) | ||
601 | +#define DXEPCTL_MPS_MASK (0x7ff << 0) | ||
602 | +#define DXEPCTL_MPS_SHIFT 0 | ||
603 | +#define DXEPCTL_MPS_LIMIT 0x7ff | ||
604 | +#define DXEPCTL_MPS(_x) ((_x) << 0) | ||
605 | + | ||
606 | +#define DIEPINT(_a) HSOTG_REG(0x908 + ((_a) * 0x20)) | ||
607 | +#define DOEPINT(_a) HSOTG_REG(0xB08 + ((_a) * 0x20)) | ||
608 | +#define DXEPINT_SETUP_RCVD BIT(15) | ||
609 | +#define DXEPINT_NYETINTRPT BIT(14) | ||
610 | +#define DXEPINT_NAKINTRPT BIT(13) | ||
611 | +#define DXEPINT_BBLEERRINTRPT BIT(12) | ||
612 | +#define DXEPINT_PKTDRPSTS BIT(11) | ||
613 | +#define DXEPINT_BNAINTR BIT(9) | ||
614 | +#define DXEPINT_TXFIFOUNDRN BIT(8) | ||
615 | +#define DXEPINT_OUTPKTERR BIT(8) | ||
616 | +#define DXEPINT_TXFEMP BIT(7) | ||
617 | +#define DXEPINT_INEPNAKEFF BIT(6) | ||
618 | +#define DXEPINT_BACK2BACKSETUP BIT(6) | ||
619 | +#define DXEPINT_INTKNEPMIS BIT(5) | ||
620 | +#define DXEPINT_STSPHSERCVD BIT(5) | ||
621 | +#define DXEPINT_INTKNTXFEMP BIT(4) | ||
622 | +#define DXEPINT_OUTTKNEPDIS BIT(4) | ||
623 | +#define DXEPINT_TIMEOUT BIT(3) | ||
624 | +#define DXEPINT_SETUP BIT(3) | ||
625 | +#define DXEPINT_AHBERR BIT(2) | ||
626 | +#define DXEPINT_EPDISBLD BIT(1) | ||
627 | +#define DXEPINT_XFERCOMPL BIT(0) | ||
628 | + | ||
629 | +#define DIEPTSIZ0 HSOTG_REG(0x910) | ||
630 | +#define DIEPTSIZ0_PKTCNT_MASK (0x3 << 19) | ||
631 | +#define DIEPTSIZ0_PKTCNT_SHIFT 19 | ||
632 | +#define DIEPTSIZ0_PKTCNT_LIMIT 0x3 | ||
633 | +#define DIEPTSIZ0_PKTCNT(_x) ((_x) << 19) | ||
634 | +#define DIEPTSIZ0_XFERSIZE_MASK (0x7f << 0) | ||
635 | +#define DIEPTSIZ0_XFERSIZE_SHIFT 0 | ||
636 | +#define DIEPTSIZ0_XFERSIZE_LIMIT 0x7f | ||
637 | +#define DIEPTSIZ0_XFERSIZE(_x) ((_x) << 0) | ||
638 | + | ||
639 | +#define DOEPTSIZ0 HSOTG_REG(0xB10) | ||
640 | +#define DOEPTSIZ0_SUPCNT_MASK (0x3 << 29) | ||
641 | +#define DOEPTSIZ0_SUPCNT_SHIFT 29 | ||
642 | +#define DOEPTSIZ0_SUPCNT_LIMIT 0x3 | ||
643 | +#define DOEPTSIZ0_SUPCNT(_x) ((_x) << 29) | ||
644 | +#define DOEPTSIZ0_PKTCNT BIT(19) | ||
645 | +#define DOEPTSIZ0_XFERSIZE_MASK (0x7f << 0) | ||
646 | +#define DOEPTSIZ0_XFERSIZE_SHIFT 0 | ||
647 | + | ||
648 | +#define DIEPTSIZ(_a) HSOTG_REG(0x910 + ((_a) * 0x20)) | ||
649 | +#define DOEPTSIZ(_a) HSOTG_REG(0xB10 + ((_a) * 0x20)) | ||
650 | +#define DXEPTSIZ_MC_MASK (0x3 << 29) | ||
651 | +#define DXEPTSIZ_MC_SHIFT 29 | ||
652 | +#define DXEPTSIZ_MC_LIMIT 0x3 | ||
653 | +#define DXEPTSIZ_MC(_x) ((_x) << 29) | ||
654 | +#define DXEPTSIZ_PKTCNT_MASK (0x3ff << 19) | ||
655 | +#define DXEPTSIZ_PKTCNT_SHIFT 19 | ||
656 | +#define DXEPTSIZ_PKTCNT_LIMIT 0x3ff | ||
657 | +#define DXEPTSIZ_PKTCNT_GET(_v) (((_v) >> 19) & 0x3ff) | ||
658 | +#define DXEPTSIZ_PKTCNT(_x) ((_x) << 19) | ||
659 | +#define DXEPTSIZ_XFERSIZE_MASK (0x7ffff << 0) | ||
660 | +#define DXEPTSIZ_XFERSIZE_SHIFT 0 | ||
661 | +#define DXEPTSIZ_XFERSIZE_LIMIT 0x7ffff | ||
662 | +#define DXEPTSIZ_XFERSIZE_GET(_v) (((_v) >> 0) & 0x7ffff) | ||
663 | +#define DXEPTSIZ_XFERSIZE(_x) ((_x) << 0) | ||
664 | + | ||
665 | +#define DIEPDMA(_a) HSOTG_REG(0x914 + ((_a) * 0x20)) | ||
666 | +#define DOEPDMA(_a) HSOTG_REG(0xB14 + ((_a) * 0x20)) | ||
667 | + | ||
668 | +#define DTXFSTS(_a) HSOTG_REG(0x918 + ((_a) * 0x20)) | ||
669 | + | ||
670 | +#define PCGCTL HSOTG_REG(0x0e00) | ||
671 | +#define PCGCTL_IF_DEV_MODE BIT(31) | ||
672 | +#define PCGCTL_P2HD_PRT_SPD_MASK (0x3 << 29) | ||
673 | +#define PCGCTL_P2HD_PRT_SPD_SHIFT 29 | ||
674 | +#define PCGCTL_P2HD_DEV_ENUM_SPD_MASK (0x3 << 27) | ||
675 | +#define PCGCTL_P2HD_DEV_ENUM_SPD_SHIFT 27 | ||
676 | +#define PCGCTL_MAC_DEV_ADDR_MASK (0x7f << 20) | ||
677 | +#define PCGCTL_MAC_DEV_ADDR_SHIFT 20 | ||
678 | +#define PCGCTL_MAX_TERMSEL BIT(19) | ||
679 | +#define PCGCTL_MAX_XCVRSELECT_MASK (0x3 << 17) | ||
680 | +#define PCGCTL_MAX_XCVRSELECT_SHIFT 17 | ||
681 | +#define PCGCTL_PORT_POWER BIT(16) | ||
682 | +#define PCGCTL_PRT_CLK_SEL_MASK (0x3 << 14) | ||
683 | +#define PCGCTL_PRT_CLK_SEL_SHIFT 14 | ||
684 | +#define PCGCTL_ESS_REG_RESTORED BIT(13) | ||
685 | +#define PCGCTL_EXTND_HIBER_SWITCH BIT(12) | ||
686 | +#define PCGCTL_EXTND_HIBER_PWRCLMP BIT(11) | ||
687 | +#define PCGCTL_ENBL_EXTND_HIBER BIT(10) | ||
688 | +#define PCGCTL_RESTOREMODE BIT(9) | ||
689 | +#define PCGCTL_RESETAFTSUSP BIT(8) | ||
690 | +#define PCGCTL_DEEP_SLEEP BIT(7) | ||
691 | +#define PCGCTL_PHY_IN_SLEEP BIT(6) | ||
692 | +#define PCGCTL_ENBL_SLEEP_GATING BIT(5) | ||
693 | +#define PCGCTL_RSTPDWNMODULE BIT(3) | ||
694 | +#define PCGCTL_PWRCLMP BIT(2) | ||
695 | +#define PCGCTL_GATEHCLK BIT(1) | ||
696 | +#define PCGCTL_STOPPCLK BIT(0) | ||
697 | + | ||
698 | +#define PCGCCTL1 HSOTG_REG(0xe04) | ||
699 | +#define PCGCCTL1_TIMER (0x3 << 1) | ||
700 | +#define PCGCCTL1_GATEEN BIT(0) | ||
701 | + | ||
702 | +#define EPFIFO(_a) HSOTG_REG(0x1000 + ((_a) * 0x1000)) | ||
703 | + | ||
704 | +/* Host Mode Registers */ | ||
705 | + | ||
706 | +#define HCFG HSOTG_REG(0x0400) | ||
707 | +#define HCFG_MODECHTIMEN BIT(31) | ||
708 | +#define HCFG_PERSCHEDENA BIT(26) | ||
709 | +#define HCFG_FRLISTEN_MASK (0x3 << 24) | ||
710 | +#define HCFG_FRLISTEN_SHIFT 24 | ||
711 | +#define HCFG_FRLISTEN_8 (0 << 24) | ||
712 | +#define FRLISTEN_8_SIZE 8 | ||
713 | +#define HCFG_FRLISTEN_16 BIT(24) | ||
714 | +#define FRLISTEN_16_SIZE 16 | ||
715 | +#define HCFG_FRLISTEN_32 (2 << 24) | ||
716 | +#define FRLISTEN_32_SIZE 32 | ||
717 | +#define HCFG_FRLISTEN_64 (3 << 24) | ||
718 | +#define FRLISTEN_64_SIZE 64 | ||
719 | +#define HCFG_DESCDMA BIT(23) | ||
720 | +#define HCFG_RESVALID_MASK (0xff << 8) | ||
721 | +#define HCFG_RESVALID_SHIFT 8 | ||
722 | +#define HCFG_ENA32KHZ BIT(7) | ||
723 | +#define HCFG_FSLSSUPP BIT(2) | ||
724 | +#define HCFG_FSLSPCLKSEL_MASK (0x3 << 0) | ||
725 | +#define HCFG_FSLSPCLKSEL_SHIFT 0 | ||
726 | +#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 | ||
727 | +#define HCFG_FSLSPCLKSEL_48_MHZ 1 | ||
728 | +#define HCFG_FSLSPCLKSEL_6_MHZ 2 | ||
729 | + | ||
730 | +#define HFIR HSOTG_REG(0x0404) | ||
731 | +#define HFIR_FRINT_MASK (0xffff << 0) | ||
732 | +#define HFIR_FRINT_SHIFT 0 | ||
733 | +#define HFIR_RLDCTRL BIT(16) | ||
734 | + | ||
735 | +#define HFNUM HSOTG_REG(0x0408) | ||
736 | +#define HFNUM_FRREM_MASK (0xffff << 16) | ||
737 | +#define HFNUM_FRREM_SHIFT 16 | ||
738 | +#define HFNUM_FRNUM_MASK (0xffff << 0) | ||
739 | +#define HFNUM_FRNUM_SHIFT 0 | ||
740 | +#define HFNUM_MAX_FRNUM 0x3fff | ||
741 | + | ||
742 | +#define HPTXSTS HSOTG_REG(0x0410) | ||
743 | +#define TXSTS_QTOP_ODD BIT(31) | ||
744 | +#define TXSTS_QTOP_CHNEP_MASK (0xf << 27) | ||
745 | +#define TXSTS_QTOP_CHNEP_SHIFT 27 | ||
746 | +#define TXSTS_QTOP_TOKEN_MASK (0x3 << 25) | ||
747 | +#define TXSTS_QTOP_TOKEN_SHIFT 25 | ||
748 | +#define TXSTS_QTOP_TERMINATE BIT(24) | ||
749 | +#define TXSTS_QSPCAVAIL_MASK (0xff << 16) | ||
750 | +#define TXSTS_QSPCAVAIL_SHIFT 16 | ||
751 | +#define TXSTS_FSPCAVAIL_MASK (0xffff << 0) | ||
752 | +#define TXSTS_FSPCAVAIL_SHIFT 0 | ||
753 | + | ||
754 | +#define HAINT HSOTG_REG(0x0414) | ||
755 | +#define HAINTMSK HSOTG_REG(0x0418) | ||
756 | +#define HFLBADDR HSOTG_REG(0x041c) | ||
757 | + | ||
758 | +#define HPRT0 HSOTG_REG(0x0440) | ||
759 | +#define HPRT0_SPD_MASK (0x3 << 17) | ||
760 | +#define HPRT0_SPD_SHIFT 17 | ||
761 | +#define HPRT0_SPD_HIGH_SPEED 0 | ||
762 | +#define HPRT0_SPD_FULL_SPEED 1 | ||
763 | +#define HPRT0_SPD_LOW_SPEED 2 | ||
764 | +#define HPRT0_TSTCTL_MASK (0xf << 13) | ||
765 | +#define HPRT0_TSTCTL_SHIFT 13 | ||
766 | +#define HPRT0_PWR BIT(12) | ||
767 | +#define HPRT0_LNSTS_MASK (0x3 << 10) | ||
768 | +#define HPRT0_LNSTS_SHIFT 10 | ||
769 | +#define HPRT0_RST BIT(8) | ||
770 | +#define HPRT0_SUSP BIT(7) | ||
771 | +#define HPRT0_RES BIT(6) | ||
772 | +#define HPRT0_OVRCURRCHG BIT(5) | ||
773 | +#define HPRT0_OVRCURRACT BIT(4) | ||
774 | +#define HPRT0_ENACHG BIT(3) | ||
775 | +#define HPRT0_ENA BIT(2) | ||
776 | +#define HPRT0_CONNDET BIT(1) | ||
777 | +#define HPRT0_CONNSTS BIT(0) | ||
778 | + | ||
779 | +#define HCCHAR(_ch) HSOTG_REG(0x0500 + 0x20 * (_ch)) | ||
780 | +#define HCCHAR_CHENA BIT(31) | ||
781 | +#define HCCHAR_CHDIS BIT(30) | ||
782 | +#define HCCHAR_ODDFRM BIT(29) | ||
783 | +#define HCCHAR_DEVADDR_MASK (0x7f << 22) | ||
784 | +#define HCCHAR_DEVADDR_SHIFT 22 | ||
785 | +#define HCCHAR_MULTICNT_MASK (0x3 << 20) | ||
786 | +#define HCCHAR_MULTICNT_SHIFT 20 | ||
787 | +#define HCCHAR_EPTYPE_MASK (0x3 << 18) | ||
788 | +#define HCCHAR_EPTYPE_SHIFT 18 | ||
789 | +#define HCCHAR_LSPDDEV BIT(17) | ||
790 | +#define HCCHAR_EPDIR BIT(15) | ||
791 | +#define HCCHAR_EPNUM_MASK (0xf << 11) | ||
792 | +#define HCCHAR_EPNUM_SHIFT 11 | ||
793 | +#define HCCHAR_MPS_MASK (0x7ff << 0) | ||
794 | +#define HCCHAR_MPS_SHIFT 0 | ||
795 | + | ||
796 | +#define HCSPLT(_ch) HSOTG_REG(0x0504 + 0x20 * (_ch)) | ||
797 | +#define HCSPLT_SPLTENA BIT(31) | ||
798 | +#define HCSPLT_COMPSPLT BIT(16) | ||
799 | +#define HCSPLT_XACTPOS_MASK (0x3 << 14) | ||
800 | +#define HCSPLT_XACTPOS_SHIFT 14 | ||
801 | +#define HCSPLT_XACTPOS_MID 0 | ||
802 | +#define HCSPLT_XACTPOS_END 1 | ||
803 | +#define HCSPLT_XACTPOS_BEGIN 2 | ||
804 | +#define HCSPLT_XACTPOS_ALL 3 | ||
805 | +#define HCSPLT_HUBADDR_MASK (0x7f << 7) | ||
806 | +#define HCSPLT_HUBADDR_SHIFT 7 | ||
807 | +#define HCSPLT_PRTADDR_MASK (0x7f << 0) | ||
808 | +#define HCSPLT_PRTADDR_SHIFT 0 | ||
809 | + | ||
810 | +#define HCINT(_ch) HSOTG_REG(0x0508 + 0x20 * (_ch)) | ||
811 | +#define HCINTMSK(_ch) HSOTG_REG(0x050c + 0x20 * (_ch)) | ||
812 | +#define HCINTMSK_RESERVED14_31 (0x3ffff << 14) | ||
813 | +#define HCINTMSK_FRM_LIST_ROLL BIT(13) | ||
814 | +#define HCINTMSK_XCS_XACT BIT(12) | ||
815 | +#define HCINTMSK_BNA BIT(11) | ||
816 | +#define HCINTMSK_DATATGLERR BIT(10) | ||
817 | +#define HCINTMSK_FRMOVRUN BIT(9) | ||
818 | +#define HCINTMSK_BBLERR BIT(8) | ||
819 | +#define HCINTMSK_XACTERR BIT(7) | ||
820 | +#define HCINTMSK_NYET BIT(6) | ||
821 | +#define HCINTMSK_ACK BIT(5) | ||
822 | +#define HCINTMSK_NAK BIT(4) | ||
823 | +#define HCINTMSK_STALL BIT(3) | ||
824 | +#define HCINTMSK_AHBERR BIT(2) | ||
825 | +#define HCINTMSK_CHHLTD BIT(1) | ||
826 | +#define HCINTMSK_XFERCOMPL BIT(0) | ||
827 | + | ||
828 | +#define HCTSIZ(_ch) HSOTG_REG(0x0510 + 0x20 * (_ch)) | ||
829 | +#define TSIZ_DOPNG BIT(31) | ||
830 | +#define TSIZ_SC_MC_PID_MASK (0x3 << 29) | ||
831 | +#define TSIZ_SC_MC_PID_SHIFT 29 | ||
832 | +#define TSIZ_SC_MC_PID_DATA0 0 | ||
833 | +#define TSIZ_SC_MC_PID_DATA2 1 | ||
834 | +#define TSIZ_SC_MC_PID_DATA1 2 | ||
835 | +#define TSIZ_SC_MC_PID_MDATA 3 | ||
836 | +#define TSIZ_SC_MC_PID_SETUP 3 | ||
837 | +#define TSIZ_PKTCNT_MASK (0x3ff << 19) | ||
838 | +#define TSIZ_PKTCNT_SHIFT 19 | ||
839 | +#define TSIZ_NTD_MASK (0xff << 8) | ||
840 | +#define TSIZ_NTD_SHIFT 8 | ||
841 | +#define TSIZ_SCHINFO_MASK (0xff << 0) | ||
842 | +#define TSIZ_SCHINFO_SHIFT 0 | ||
843 | +#define TSIZ_XFERSIZE_MASK (0x7ffff << 0) | ||
844 | +#define TSIZ_XFERSIZE_SHIFT 0 | ||
845 | + | ||
846 | +#define HCDMA(_ch) HSOTG_REG(0x0514 + 0x20 * (_ch)) | ||
847 | + | ||
848 | +#define HCDMAB(_ch) HSOTG_REG(0x051c + 0x20 * (_ch)) | ||
849 | + | ||
850 | +#define HCFIFO(_ch) HSOTG_REG(0x1000 + 0x1000 * (_ch)) | ||
851 | + | ||
852 | +/** | ||
853 | + * struct dwc2_dma_desc - DMA descriptor structure, | ||
854 | + * used for both host and gadget modes | ||
855 | + * | ||
856 | + * @status: DMA descriptor status quadlet | ||
857 | + * @buf: DMA descriptor data buffer pointer | ||
858 | + * | ||
859 | + * DMA Descriptor structure contains two quadlets: | ||
860 | + * Status quadlet and Data buffer pointer. | ||
861 | + */ | ||
862 | +struct dwc2_dma_desc { | ||
863 | + uint32_t status; | ||
864 | + uint32_t buf; | ||
865 | +} __packed; | ||
866 | + | ||
867 | +/* Host Mode DMA descriptor status quadlet */ | ||
868 | + | ||
869 | +#define HOST_DMA_A BIT(31) | ||
870 | +#define HOST_DMA_STS_MASK (0x3 << 28) | ||
871 | +#define HOST_DMA_STS_SHIFT 28 | ||
872 | +#define HOST_DMA_STS_PKTERR BIT(28) | ||
873 | +#define HOST_DMA_EOL BIT(26) | ||
874 | +#define HOST_DMA_IOC BIT(25) | ||
875 | +#define HOST_DMA_SUP BIT(24) | ||
876 | +#define HOST_DMA_ALT_QTD BIT(23) | ||
877 | +#define HOST_DMA_QTD_OFFSET_MASK (0x3f << 17) | ||
878 | +#define HOST_DMA_QTD_OFFSET_SHIFT 17 | ||
879 | +#define HOST_DMA_ISOC_NBYTES_MASK (0xfff << 0) | ||
880 | +#define HOST_DMA_ISOC_NBYTES_SHIFT 0 | ||
881 | +#define HOST_DMA_NBYTES_MASK (0x1ffff << 0) | ||
882 | +#define HOST_DMA_NBYTES_SHIFT 0 | ||
883 | +#define HOST_DMA_NBYTES_LIMIT 131071 | ||
884 | + | ||
885 | +/* Device Mode DMA descriptor status quadlet */ | ||
886 | + | ||
887 | +#define DEV_DMA_BUFF_STS_MASK (0x3 << 30) | ||
888 | +#define DEV_DMA_BUFF_STS_SHIFT 30 | ||
889 | +#define DEV_DMA_BUFF_STS_HREADY 0 | ||
890 | +#define DEV_DMA_BUFF_STS_DMABUSY 1 | ||
891 | +#define DEV_DMA_BUFF_STS_DMADONE 2 | ||
892 | +#define DEV_DMA_BUFF_STS_HBUSY 3 | ||
893 | +#define DEV_DMA_STS_MASK (0x3 << 28) | ||
894 | +#define DEV_DMA_STS_SHIFT 28 | ||
895 | +#define DEV_DMA_STS_SUCC 0 | ||
896 | +#define DEV_DMA_STS_BUFF_FLUSH 1 | ||
897 | +#define DEV_DMA_STS_BUFF_ERR 3 | ||
898 | +#define DEV_DMA_L BIT(27) | ||
899 | +#define DEV_DMA_SHORT BIT(26) | ||
900 | +#define DEV_DMA_IOC BIT(25) | ||
901 | +#define DEV_DMA_SR BIT(24) | ||
902 | +#define DEV_DMA_MTRF BIT(23) | ||
903 | +#define DEV_DMA_ISOC_PID_MASK (0x3 << 23) | ||
904 | +#define DEV_DMA_ISOC_PID_SHIFT 23 | ||
905 | +#define DEV_DMA_ISOC_PID_DATA0 0 | ||
906 | +#define DEV_DMA_ISOC_PID_DATA2 1 | ||
907 | +#define DEV_DMA_ISOC_PID_DATA1 2 | ||
908 | +#define DEV_DMA_ISOC_PID_MDATA 3 | ||
909 | +#define DEV_DMA_ISOC_FRNUM_MASK (0x7ff << 12) | ||
910 | +#define DEV_DMA_ISOC_FRNUM_SHIFT 12 | ||
911 | +#define DEV_DMA_ISOC_TX_NBYTES_MASK (0xfff << 0) | ||
912 | +#define DEV_DMA_ISOC_TX_NBYTES_LIMIT 0xfff | ||
913 | +#define DEV_DMA_ISOC_RX_NBYTES_MASK (0x7ff << 0) | ||
914 | +#define DEV_DMA_ISOC_RX_NBYTES_LIMIT 0x7ff | ||
915 | +#define DEV_DMA_ISOC_NBYTES_SHIFT 0 | ||
916 | +#define DEV_DMA_NBYTES_MASK (0xffff << 0) | ||
917 | +#define DEV_DMA_NBYTES_SHIFT 0 | ||
918 | +#define DEV_DMA_NBYTES_LIMIT 0xffff | ||
919 | + | ||
920 | +#define MAX_DMA_DESC_NUM_GENERIC 64 | ||
921 | +#define MAX_DMA_DESC_NUM_HS_ISOC 256 | ||
922 | + | ||
923 | +#endif /* __DWC2_HW_H__ */ | ||
924 | -- | 84 | -- |
925 | 2.20.1 | 85 | 2.25.1 |
926 | |||
927 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Stephen Longfield <slongfield@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Rather than passing an opcode to a helper, fully decode the | 3 | Size is used at lines 1088/1188 for the loop, which reads the last 4 |
4 | operation at translate time. Use clear_tail_16 to zap the | 4 | bytes from the crc_ptr so it does need to get increased, however it |
5 | balance of the SVE register with the AdvSIMD write. | 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 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | This was pointed out to me by clg@kaod.org during the code review of |
8 | Message-id: 20200514212831.31248-7-richard.henderson@linaro.org | 9 | a similar patch to hw/net/ftgmac100.c |
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 | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 17 | --- |
12 | target/arm/helper.h | 5 ++++- | 18 | hw/net/imx_fec.c | 8 ++++---- |
13 | target/arm/crypto_helper.c | 24 ++++++++++++++++++------ | 19 | 1 file changed, 4 insertions(+), 4 deletions(-) |
14 | target/arm/translate-a64.c | 21 +++++---------------- | ||
15 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
16 | 20 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 21 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c |
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 23 | --- a/hw/net/imx_fec.c |
20 | +++ b/target/arm/helper.h | 24 | +++ b/hw/net/imx_fec.c |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 25 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, |
22 | DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | 26 | return 0; |
23 | void, ptr, ptr, ptr, i32) | ||
24 | |||
25 | -DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | ||
26 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | ||
31 | void, ptr, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | ||
33 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/crypto_helper.c | ||
36 | +++ b/target/arm/crypto_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
38 | clear_tail_16(vd, desc); | ||
39 | } | ||
40 | |||
41 | -void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
42 | - uint32_t opcode) | ||
43 | +static inline void QEMU_ALWAYS_INLINE | ||
44 | +crypto_sm3tt(uint64_t *rd, uint64_t *rn, uint64_t *rm, | ||
45 | + uint32_t desc, uint32_t opcode) | ||
46 | { | ||
47 | - uint64_t *rd = vd; | ||
48 | - uint64_t *rn = vn; | ||
49 | - uint64_t *rm = vm; | ||
50 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
51 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
52 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
53 | + uint32_t imm2 = simd_data(desc); | ||
54 | uint32_t t; | ||
55 | |||
56 | assert(imm2 < 4); | ||
57 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
58 | /* SM3TT2B */ | ||
59 | t = cho(CR_ST_WORD(d, 3), CR_ST_WORD(d, 2), CR_ST_WORD(d, 1)); | ||
60 | } else { | ||
61 | - g_assert_not_reached(); | ||
62 | + qemu_build_not_reached(); | ||
63 | } | 27 | } |
64 | 28 | ||
65 | t += CR_ST_WORD(d, 0) + CR_ST_WORD(m, imm2); | 29 | - /* 4 bytes for the CRC. */ |
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | 30 | - size += 4; |
67 | 31 | crc = cpu_to_be32(crc32(~0, buf, size)); | |
68 | rd[0] = d.l[0]; | 32 | + /* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */ |
69 | rd[1] = d.l[1]; | 33 | + size += 4; |
70 | + | 34 | crc_ptr = (uint8_t *) &crc; |
71 | + clear_tail_16(rd, desc); | 35 | |
72 | } | 36 | /* Huge frames are truncated. */ |
73 | 37 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | |
74 | +#define DO_SM3TT(NAME, OPCODE) \ | 38 | return 0; |
75 | + void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \ | ||
76 | + { crypto_sm3tt(vd, vn, vm, desc, OPCODE); } | ||
77 | + | ||
78 | +DO_SM3TT(crypto_sm3tt1a, 0) | ||
79 | +DO_SM3TT(crypto_sm3tt1b, 1) | ||
80 | +DO_SM3TT(crypto_sm3tt2a, 2) | ||
81 | +DO_SM3TT(crypto_sm3tt2b, 3) | ||
82 | + | ||
83 | +#undef DO_SM3TT | ||
84 | + | ||
85 | static uint8_t const sm4_sbox[] = { | ||
86 | 0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, | ||
87 | 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05, | ||
88 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/translate-a64.c | ||
91 | +++ b/target/arm/translate-a64.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_xar(DisasContext *s, uint32_t insn) | ||
93 | */ | ||
94 | static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
95 | { | ||
96 | + static gen_helper_gvec_3 * const fns[4] = { | ||
97 | + gen_helper_crypto_sm3tt1a, gen_helper_crypto_sm3tt1b, | ||
98 | + gen_helper_crypto_sm3tt2a, gen_helper_crypto_sm3tt2b, | ||
99 | + }; | ||
100 | int opcode = extract32(insn, 10, 2); | ||
101 | int imm2 = extract32(insn, 12, 2); | ||
102 | int rm = extract32(insn, 16, 5); | ||
103 | int rn = extract32(insn, 5, 5); | ||
104 | int rd = extract32(insn, 0, 5); | ||
105 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
106 | - TCGv_i32 tcg_imm2, tcg_opcode; | ||
107 | |||
108 | if (!dc_isar_feature(aa64_sm3, s)) { | ||
109 | unallocated_encoding(s); | ||
110 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
111 | return; | ||
112 | } | 39 | } |
113 | 40 | ||
114 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 41 | - /* 4 bytes for the CRC. */ |
115 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 42 | - size += 4; |
116 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | 43 | crc = cpu_to_be32(crc32(~0, buf, size)); |
117 | - tcg_imm2 = tcg_const_i32(imm2); | 44 | + /* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */ |
118 | - tcg_opcode = tcg_const_i32(opcode); | 45 | + size += 4; |
119 | - | 46 | crc_ptr = (uint8_t *) &crc; |
120 | - gen_helper_crypto_sm3tt(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr, tcg_imm2, | 47 | |
121 | - tcg_opcode); | 48 | if (shift16) { |
122 | - | ||
123 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
124 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
125 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
126 | - tcg_temp_free_i32(tcg_imm2); | ||
127 | - tcg_temp_free_i32(tcg_opcode); | ||
128 | + gen_gvec_op3_ool(s, true, rd, rn, rm, imm2, fns[opcode]); | ||
129 | } | ||
130 | |||
131 | /* C3.6 Data processing - SIMD, inc Crypto | ||
132 | -- | 49 | -- |
133 | 2.20.1 | 50 | 2.25.1 |
134 | |||
135 | diff view generated by jsdifflib |