1 | target-arm queue of various easier things that had piled | 1 | Nothing very exciting this time around... |
---|---|---|---|
2 | up while I was on holiday. | ||
3 | 2 | ||
4 | thanks | ||
5 | -- PMM | 3 | -- PMM |
6 | 4 | ||
7 | The following changes since commit 506e4a00de01e0b29fa83db5cbbc3d154253b4ea: | 5 | The following changes since commit 37a712a0f969ca2df7f01182409a6c4825cebfb5: |
8 | 6 | ||
9 | Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-3.1-20180925' into staging (2018-09-25 13:30:45 +0100) | 7 | Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging (2020-10-01 12:23:19 +0100) |
10 | 8 | ||
11 | are available in the Git repository at: | 9 | are available in the Git repository at: |
12 | 10 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180925 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201001 |
14 | 12 | ||
15 | for you to fetch changes up to 4a87106b160a3e72152443065fb92f8a1313c23d: | 13 | for you to fetch changes up to cdfaa57dcb53ba012439765a1462247dfda8595d: |
16 | 14 | ||
17 | target/arm: Start AArch32 CPUs with EL2 but not EL3 in Hyp mode (2018-09-25 14:14:07 +0100) | 15 | hw/arm/raspi: Remove use of the 'version' value in the board code (2020-10-01 15:31:01 +0100) |
18 | 16 | ||
19 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
20 | target-arm queue: | 18 | target-arm queue: |
21 | * target/arm: Fix cpu_get_tb_cpu_state() for non-SVE CPUs | 19 | * Make isar_feature_aa32_fp16_arith() handle M-profile |
22 | * hw/arm/exynos4210: fix Exynos4210 UART support | 20 | * Fix SVE splice |
23 | * hw/arm/virt-acpi-build: Add a check for memory-less NUMA nodes | 21 | * Fix SVE LDR/STR |
24 | * arm: Add BBC micro:bit machine | 22 | * Remove ignore_memory_transaction_failures on the raspi2 |
25 | * aspeed/i2c: Fix interrupt handling bugs | 23 | * raspi: Various cleanup/refactoring |
26 | * hw/arm/smmu-common: Fix the name of the iommu memory regions | ||
27 | * hw/arm/smmuv3: fix eventq recording and IRQ triggerring | ||
28 | * hw/intc/arm_gic: Document QEMU interface | ||
29 | * hw/intc/arm_gic: Drop GIC_BASE_IRQ macro | ||
30 | * hw/net/pcnet-pci: Convert away from old_mmio accessors | ||
31 | * hw/timer/cmsdk-apb-dualtimer: Add missing 'break' statements | ||
32 | * aspeed/timer: fix compile breakage with clang 3.4.2 | ||
33 | * hw/arm/aspeed: change the FMC flash model of the AST2500 evb | ||
34 | * hw/arm/aspeed: Minor code cleanups | ||
35 | * target/arm: Start AArch32 CPUs with EL2 but not EL3 in Hyp mode | ||
36 | 24 | ||
37 | ---------------------------------------------------------------- | 25 | ---------------------------------------------------------------- |
38 | Bartlomiej Zolnierkiewicz (1): | 26 | Peter Maydell (5): |
39 | hw/arm/exynos4210: fix Exynos4210 UART support | 27 | target/arm: Replace ARM_FEATURE_PXN with ID_MMFR0.VMSA check |
28 | target/arm: Move id_pfr0, id_pfr1 into ARMISARegisters | ||
29 | hw/intc/armv7m_nvic: Only show ID register values for Main Extension CPUs | ||
30 | target/arm: Add ID register values for Cortex-M0 | ||
31 | target/arm: Make isar_feature_aa32_fp16_arith() handle M-profile | ||
40 | 32 | ||
41 | Cédric Le Goater (5): | 33 | Philippe Mathieu-Daudé (11): |
42 | aspeed/i2c: interrupts should be cleared by software only | 34 | hw/arm/raspi: Define various blocks base addresses |
43 | aspeed/timer: fix compile breakage with clang 3.4.2 | 35 | hw/arm/bcm2835: Add more unimplemented peripherals |
44 | hw/arm/aspeed: change the FMC flash model of the AST2500 evb | 36 | hw/arm/raspi: Remove ignore_memory_transaction_failures on the raspi2 |
45 | hw/arm/aspeed: Add an Aspeed machine class | 37 | hw/arm/raspi: Display the board revision in the machine description |
46 | aspeed/smc: fix some alignment issues | 38 | hw/arm/raspi: Load the firmware on the first core |
39 | hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState | ||
40 | hw/arm/raspi: Avoid using TypeInfo::class_data pointer | ||
41 | hw/arm/raspi: Use more specific machine names | ||
42 | hw/arm/raspi: Introduce RaspiProcessorId enum | ||
43 | hw/arm/raspi: Use RaspiProcessorId to set the firmware load address | ||
44 | hw/arm/raspi: Remove use of the 'version' value in the board code | ||
47 | 45 | ||
48 | Eric Auger (2): | 46 | Richard Henderson (2): |
49 | hw/arm/smmu-common: Fix the name of the iommu memory regions | 47 | target/arm: Fix sve ldr/str |
50 | hw/arm/smmuv3: fix eventq recording and IRQ triggerring | 48 | target/arm: Fix SVE splice |
51 | 49 | ||
52 | Guenter Roeck (2): | 50 | include/hw/arm/bcm2835_peripherals.h | 2 + |
53 | aspeed/i2c: Handle receive command in separate function | 51 | include/hw/arm/raspi_platform.h | 51 ++++++++++-- |
54 | aspeed/i2c: Fix receive done interrupt handling | 52 | target/arm/cpu.h | 50 +++++++++-- |
53 | hw/arm/bcm2835_peripherals.c | 2 + | ||
54 | hw/arm/raspi.c | 155 +++++++++++++++++++---------------- | ||
55 | hw/intc/armv7m_nvic.c | 46 ++++++++++- | ||
56 | target/arm/cpu.c | 21 +++-- | ||
57 | target/arm/cpu64.c | 12 +-- | ||
58 | target/arm/cpu_tcg.c | 60 ++++++++++---- | ||
59 | target/arm/helper.c | 9 +- | ||
60 | target/arm/kvm64.c | 4 + | ||
61 | target/arm/translate-sve.c | 6 +- | ||
62 | 12 files changed, 286 insertions(+), 132 deletions(-) | ||
55 | 63 | ||
56 | Joel Stanley (3): | ||
57 | MAINTAINERS: Add NRF51 entry | ||
58 | arm: Add Nordic Semiconductor nRF51 SoC | ||
59 | arm: Add BBC micro:bit machine | ||
60 | |||
61 | Peter Maydell (6): | ||
62 | hw/intc/arm_gic: Document QEMU interface | ||
63 | hw/intc/arm_gic: Drop GIC_BASE_IRQ macro | ||
64 | hw/net/pcnet-pci: Convert away from old_mmio accessors | ||
65 | hw/net/pcnet-pci: Unify pcnet_ioport_read/write and pcnet_mmio_read/write | ||
66 | hw/timer/cmsdk-apb-dualtimer: Add missing 'break' statements | ||
67 | target/arm: Start AArch32 CPUs with EL2 but not EL3 in Hyp mode | ||
68 | |||
69 | Richard Henderson (1): | ||
70 | target/arm: Fix cpu_get_tb_cpu_state() for non-SVE CPUs | ||
71 | |||
72 | Shannon Zhao (1): | ||
73 | hw/arm/virt-acpi-build: Add a check for memory-less NUMA nodes | ||
74 | |||
75 | hw/arm/Makefile.objs | 1 + | ||
76 | hw/arm/smmuv3-internal.h | 26 ++--- | ||
77 | hw/intc/gic_internal.h | 2 - | ||
78 | include/hw/arm/aspeed.h | 46 +++++++++ | ||
79 | include/hw/arm/nrf51_soc.h | 41 ++++++++ | ||
80 | include/hw/intc/arm_gic.h | 43 ++++++++ | ||
81 | include/hw/timer/aspeed_timer.h | 3 +- | ||
82 | hw/arm/aspeed.c | 212 +++++++++++++--------------------------- | ||
83 | hw/arm/exynos4210.c | 8 +- | ||
84 | hw/arm/microbit.c | 67 +++++++++++++ | ||
85 | hw/arm/nrf51_soc.c | 133 +++++++++++++++++++++++++ | ||
86 | hw/arm/smmu-common.c | 6 +- | ||
87 | hw/arm/smmuv3.c | 2 +- | ||
88 | hw/arm/virt-acpi-build.c | 10 +- | ||
89 | hw/i2c/aspeed_i2c.c | 63 ++++++++---- | ||
90 | hw/intc/arm_gic.c | 31 +++--- | ||
91 | hw/intc/arm_gic_common.c | 1 - | ||
92 | hw/net/pcnet-pci.c | 98 ++----------------- | ||
93 | hw/ssi/aspeed_smc.c | 8 +- | ||
94 | hw/timer/aspeed_timer.c | 1 - | ||
95 | hw/timer/cmsdk-apb-dualtimer.c | 2 + | ||
96 | target/arm/cpu.c | 14 ++- | ||
97 | target/arm/helper.c | 45 +++++---- | ||
98 | MAINTAINERS | 8 ++ | ||
99 | default-configs/arm-softmmu.mak | 1 + | ||
100 | hw/net/trace-events | 6 -- | ||
101 | 26 files changed, 542 insertions(+), 336 deletions(-) | ||
102 | create mode 100644 include/hw/arm/aspeed.h | ||
103 | create mode 100644 include/hw/arm/nrf51_soc.h | ||
104 | create mode 100644 hw/arm/microbit.c | ||
105 | create mode 100644 hw/arm/nrf51_soc.c | ||
106 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The ARM_FEATURE_PXN bit indicates whether the CPU supports the PXN |
---|---|---|---|
2 | bit in short-descriptor translation table format descriptors. This | ||
3 | is indicated by ID_MMFR0.VMSA being at least 0b0100. Replace the | ||
4 | feature bit with an ID register check, in line with our preference | ||
5 | for ID register checks over feature bits. | ||
2 | 6 | ||
3 | Not only are the sve-related tb_flags fields unused when SVE is | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | disabled, but not all of the cpu registers are initialized properly | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | for computing same. This can corrupt other fields by ORing in -1, | 9 | Message-id: 20200910173855.4068-2-peter.maydell@linaro.org |
6 | which might result in QEMU crashing. | 10 | --- |
11 | target/arm/cpu.h | 15 ++++++++++++++- | ||
12 | target/arm/cpu.c | 1 - | ||
13 | target/arm/helper.c | 5 +++-- | ||
14 | 3 files changed, 17 insertions(+), 4 deletions(-) | ||
7 | 15 | ||
8 | This bug was not present in 3.0, but this patch is cc'd to | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
9 | stable because adf92eab90e3f5f34c285 where the bug was | 17 | index XXXXXXX..XXXXXXX 100644 |
10 | introduced was marked for stable. | 18 | --- a/target/arm/cpu.h |
11 | 19 | +++ b/target/arm/cpu.h | |
12 | Fixes: adf92eab90e3f5f34c285 | 20 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_ISAR6, FHM, 8, 4) |
13 | Cc: qemu-stable@nongnu.org (3.0.1) | 21 | FIELD(ID_ISAR6, SB, 12, 4) |
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 22 | FIELD(ID_ISAR6, SPECRES, 16, 4) |
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 23 | |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | +FIELD(ID_MMFR0, VMSA, 0, 4) |
17 | --- | 25 | +FIELD(ID_MMFR0, PMSA, 4, 4) |
18 | target/arm/helper.c | 45 ++++++++++++++++++++++++--------------------- | 26 | +FIELD(ID_MMFR0, OUTERSHR, 8, 4) |
19 | 1 file changed, 24 insertions(+), 21 deletions(-) | 27 | +FIELD(ID_MMFR0, SHARELVL, 12, 4) |
20 | 28 | +FIELD(ID_MMFR0, TCM, 16, 4) | |
29 | +FIELD(ID_MMFR0, AUXREG, 20, 4) | ||
30 | +FIELD(ID_MMFR0, FCSE, 24, 4) | ||
31 | +FIELD(ID_MMFR0, INNERSHR, 28, 4) | ||
32 | + | ||
33 | FIELD(ID_MMFR3, CMAINTVA, 0, 4) | ||
34 | FIELD(ID_MMFR3, CMAINTSW, 4, 4) | ||
35 | FIELD(ID_MMFR3, BPMAINT, 8, 4) | ||
36 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | ||
37 | ARM_FEATURE_CACHE_DIRTY_REG, /* 1136/1176 cache dirty status register */ | ||
38 | ARM_FEATURE_CACHE_BLOCK_OPS, /* v6 optional cache block operations */ | ||
39 | ARM_FEATURE_MPIDR, /* has cp15 MPIDR */ | ||
40 | - ARM_FEATURE_PXN, /* has Privileged Execute Never bit */ | ||
41 | ARM_FEATURE_LPAE, /* has Large Physical Address Extension */ | ||
42 | ARM_FEATURE_V8, | ||
43 | ARM_FEATURE_AARCH64, /* supports 64 bit mode */ | ||
44 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) | ||
45 | return FIELD_EX32(id->mvfr2, MVFR2, FPMISC) >= 4; | ||
46 | } | ||
47 | |||
48 | +static inline bool isar_feature_aa32_pxn(const ARMISARegisters *id) | ||
49 | +{ | ||
50 | + return FIELD_EX32(id->id_mmfr0, ID_MMFR0, VMSA) >= 4; | ||
51 | +} | ||
52 | + | ||
53 | static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) | ||
54 | { | ||
55 | return FIELD_EX32(id->id_mmfr3, ID_MMFR3, PAN) != 0; | ||
56 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/cpu.c | ||
59 | +++ b/target/arm/cpu.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
61 | } | ||
62 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
63 | set_feature(env, ARM_FEATURE_V7MP); | ||
64 | - set_feature(env, ARM_FEATURE_PXN); | ||
65 | } | ||
66 | if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
67 | set_feature(env, ARM_FEATURE_CBAR); | ||
21 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 68 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
22 | index XXXXXXX..XXXXXXX 100644 | 69 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/helper.c | 70 | --- a/target/arm/helper.c |
24 | +++ b/target/arm/helper.c | 71 | +++ b/target/arm/helper.c |
25 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 72 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, |
26 | uint32_t flags; | 73 | target_ulong *page_size, ARMMMUFaultInfo *fi) |
27 | 74 | { | |
28 | if (is_a64(env)) { | 75 | CPUState *cs = env_cpu(env); |
29 | - int sve_el = sve_exception_el(env); | 76 | + ARMCPU *cpu = env_archcpu(env); |
30 | - uint32_t zcr_len; | 77 | int level = 1; |
31 | - | 78 | uint32_t table; |
32 | *pc = env->pc; | 79 | uint32_t desc; |
33 | flags = ARM_TBFLAG_AARCH64_STATE_MASK; | 80 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, |
34 | /* Get control bits for tagged addresses */ | 81 | goto do_fault; |
35 | flags |= (arm_regime_tbi0(env, mmu_idx) << ARM_TBFLAG_TBI0_SHIFT); | 82 | } |
36 | flags |= (arm_regime_tbi1(env, mmu_idx) << ARM_TBFLAG_TBI1_SHIFT); | 83 | type = (desc & 3); |
37 | - flags |= sve_el << ARM_TBFLAG_SVEEXC_EL_SHIFT; | 84 | - if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) { |
38 | 85 | + if (type == 0 || (type == 3 && !cpu_isar_feature(aa32_pxn, cpu))) { | |
39 | - /* If SVE is disabled, but FP is enabled, | 86 | /* Section translation fault, or attempt to use the encoding |
40 | - then the effective len is 0. */ | 87 | * which is Reserved on implementations without PXN. |
41 | - if (sve_el != 0 && fp_el == 0) { | 88 | */ |
42 | - zcr_len = 0; | 89 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, |
43 | - } else { | 90 | pxn = desc & 1; |
44 | - int current_el = arm_current_el(env); | 91 | ns = extract32(desc, 19, 1); |
45 | - ARMCPU *cpu = arm_env_get_cpu(env); | 92 | } else { |
46 | + if (arm_feature(env, ARM_FEATURE_SVE)) { | 93 | - if (arm_feature(env, ARM_FEATURE_PXN)) { |
47 | + int sve_el = sve_exception_el(env); | 94 | + if (cpu_isar_feature(aa32_pxn, cpu)) { |
48 | + uint32_t zcr_len; | 95 | pxn = (desc >> 2) & 1; |
49 | |||
50 | - zcr_len = cpu->sve_max_vq - 1; | ||
51 | - if (current_el <= 1) { | ||
52 | - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
53 | - } | ||
54 | - if (current_el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
55 | - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); | ||
56 | - } | ||
57 | - if (current_el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { | ||
58 | - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
59 | + /* If SVE is disabled, but FP is enabled, | ||
60 | + * then the effective len is 0. | ||
61 | + */ | ||
62 | + if (sve_el != 0 && fp_el == 0) { | ||
63 | + zcr_len = 0; | ||
64 | + } else { | ||
65 | + int current_el = arm_current_el(env); | ||
66 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
67 | + | ||
68 | + zcr_len = cpu->sve_max_vq - 1; | ||
69 | + if (current_el <= 1) { | ||
70 | + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
71 | + } | ||
72 | + if (current_el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
73 | + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); | ||
74 | + } | ||
75 | + if (current_el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { | ||
76 | + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
77 | + } | ||
78 | } | ||
79 | + flags |= sve_el << ARM_TBFLAG_SVEEXC_EL_SHIFT; | ||
80 | + flags |= zcr_len << ARM_TBFLAG_ZCR_LEN_SHIFT; | ||
81 | } | 96 | } |
82 | - flags |= zcr_len << ARM_TBFLAG_ZCR_LEN_SHIFT; | 97 | ns = extract32(desc, 3, 1); |
83 | } else { | ||
84 | *pc = env->regs[15]; | ||
85 | flags = (env->thumb << ARM_TBFLAG_THUMB_SHIFT) | ||
86 | -- | 98 | -- |
87 | 2.19.0 | 99 | 2.20.1 |
88 | 100 | ||
89 | 101 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | ||
2 | 1 | ||
3 | commit 97274d0c05d4 ("hw/char/exynos4210_uart.c: Remove unneeded | ||
4 | handling of NULL chardev") broke Exynos4210 support as it removed | ||
5 | NULL 'Chardev *chr' handling from exynos4210_uart_create() and | ||
6 | currently exynos4210_init() always passes NULL as 'Chardev *chr' | ||
7 | argument to exynos4210_uart_create() calls. Fix it by adding | ||
8 | missing serial_hd() calls to exynos4210_init(). | ||
9 | |||
10 | Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | ||
11 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 9310418.Wg32kryeWE@amdc3058 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/arm/exynos4210.c | 8 ++++---- | ||
17 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
18 | |||
19 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/exynos4210.c | ||
22 | +++ b/hw/arm/exynos4210.c | ||
23 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
24 | |||
25 | /*** UARTs ***/ | ||
26 | exynos4210_uart_create(EXYNOS4210_UART0_BASE_ADDR, | ||
27 | - EXYNOS4210_UART0_FIFO_SIZE, 0, NULL, | ||
28 | + EXYNOS4210_UART0_FIFO_SIZE, 0, serial_hd(0), | ||
29 | s->irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 0)]); | ||
30 | |||
31 | exynos4210_uart_create(EXYNOS4210_UART1_BASE_ADDR, | ||
32 | - EXYNOS4210_UART1_FIFO_SIZE, 1, NULL, | ||
33 | + EXYNOS4210_UART1_FIFO_SIZE, 1, serial_hd(1), | ||
34 | s->irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 1)]); | ||
35 | |||
36 | exynos4210_uart_create(EXYNOS4210_UART2_BASE_ADDR, | ||
37 | - EXYNOS4210_UART2_FIFO_SIZE, 2, NULL, | ||
38 | + EXYNOS4210_UART2_FIFO_SIZE, 2, serial_hd(2), | ||
39 | s->irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 2)]); | ||
40 | |||
41 | exynos4210_uart_create(EXYNOS4210_UART3_BASE_ADDR, | ||
42 | - EXYNOS4210_UART3_FIFO_SIZE, 3, NULL, | ||
43 | + EXYNOS4210_UART3_FIFO_SIZE, 3, serial_hd(3), | ||
44 | s->irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 3)]); | ||
45 | |||
46 | /*** SD/MMC host controllers ***/ | ||
47 | -- | ||
48 | 2.19.0 | ||
49 | |||
50 | diff view generated by jsdifflib |
1 | The ARMv8 architecture defines that an AArch32 CPU starts | 1 | Move the id_pfr0 and id_pfr1 fields into the ARMISARegisters |
---|---|---|---|
2 | in SVC mode, unless EL2 is the highest available EL, in | 2 | sub-struct. We're going to want id_pfr1 for an isar_features |
3 | which case it starts in Hyp mode. (In ARMv7 a CPU with EL2 | 3 | check, and moving both at the same time avoids an odd |
4 | but not EL3 was not a valid configuration, but we don't | 4 | inconsistency. |
5 | specifically reject this if the user asks for one.) | 5 | |
6 | Changes other than the ones to cpu.h and kvm64.c made | ||
7 | automatically with: | ||
8 | perl -p -i -e 's/cpu->id_pfr/cpu->isar.id_pfr/' target/arm/*.c hw/intc/armv7m_nvic.c | ||
6 | 9 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180823135047.16525-1-peter.maydell@linaro.org | 12 | Message-id: 20200910173855.4068-3-peter.maydell@linaro.org |
10 | --- | 13 | --- |
11 | target/arm/cpu.c | 14 ++++++++++++-- | 14 | target/arm/cpu.h | 4 ++-- |
12 | 1 file changed, 12 insertions(+), 2 deletions(-) | 15 | hw/intc/armv7m_nvic.c | 4 ++-- |
13 | 16 | target/arm/cpu.c | 20 ++++++++++---------- | |
17 | target/arm/cpu64.c | 12 ++++++------ | ||
18 | target/arm/cpu_tcg.c | 36 ++++++++++++++++++------------------ | ||
19 | target/arm/helper.c | 4 ++-- | ||
20 | target/arm/kvm64.c | 4 ++++ | ||
21 | 7 files changed, 44 insertions(+), 40 deletions(-) | ||
22 | |||
23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/cpu.h | ||
26 | +++ b/target/arm/cpu.h | ||
27 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
28 | uint32_t id_mmfr2; | ||
29 | uint32_t id_mmfr3; | ||
30 | uint32_t id_mmfr4; | ||
31 | + uint32_t id_pfr0; | ||
32 | + uint32_t id_pfr1; | ||
33 | uint32_t mvfr0; | ||
34 | uint32_t mvfr1; | ||
35 | uint32_t mvfr2; | ||
36 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
37 | uint32_t reset_fpsid; | ||
38 | uint32_t ctr; | ||
39 | uint32_t reset_sctlr; | ||
40 | - uint32_t id_pfr0; | ||
41 | - uint32_t id_pfr1; | ||
42 | uint64_t pmceid0; | ||
43 | uint64_t pmceid1; | ||
44 | uint32_t id_afr0; | ||
45 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/intc/armv7m_nvic.c | ||
48 | +++ b/hw/intc/armv7m_nvic.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
50 | "Aux Fault status registers unimplemented\n"); | ||
51 | return 0; | ||
52 | case 0xd40: /* PFR0. */ | ||
53 | - return cpu->id_pfr0; | ||
54 | + return cpu->isar.id_pfr0; | ||
55 | case 0xd44: /* PFR1. */ | ||
56 | - return cpu->id_pfr1; | ||
57 | + return cpu->isar.id_pfr1; | ||
58 | case 0xd48: /* DFR0. */ | ||
59 | return cpu->isar.id_dfr0; | ||
60 | case 0xd4c: /* AFR0. */ | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 63 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 64 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
19 | env->cp15.c15_cpar = 1; | 66 | /* Disable the security extension feature bits in the processor feature |
67 | * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. | ||
68 | */ | ||
69 | - cpu->id_pfr1 &= ~0xf0; | ||
70 | + cpu->isar.id_pfr1 &= ~0xf0; | ||
71 | cpu->isar.id_aa64pfr0 &= ~0xf000; | ||
20 | } | 72 | } |
21 | #else | 73 | |
22 | - /* SVC mode with interrupts disabled. */ | 74 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
23 | - env->uncached_cpsr = ARM_CPU_MODE_SVC; | 75 | * id_aa64pfr0_el1[11:8]. |
24 | + | 76 | */ |
25 | + /* | 77 | cpu->isar.id_aa64pfr0 &= ~0xf00; |
26 | + * If the highest available EL is EL2, AArch32 will start in Hyp | 78 | - cpu->id_pfr1 &= ~0xf000; |
27 | + * mode; otherwise it starts in SVC. Note that if we start in | 79 | + cpu->isar.id_pfr1 &= ~0xf000; |
28 | + * AArch64 then these values in the uncached_cpsr will be ignored. | 80 | } |
29 | + */ | 81 | |
30 | + if (arm_feature(env, ARM_FEATURE_EL2) && | 82 | #ifndef CONFIG_USER_ONLY |
31 | + !arm_feature(env, ARM_FEATURE_EL3)) { | 83 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) |
32 | + env->uncached_cpsr = ARM_CPU_MODE_HYP; | 84 | cpu->isar.mvfr1 = 0x00011111; |
33 | + } else { | 85 | cpu->ctr = 0x82048004; |
34 | + env->uncached_cpsr = ARM_CPU_MODE_SVC; | 86 | cpu->reset_sctlr = 0x00c50078; |
35 | + } | 87 | - cpu->id_pfr0 = 0x1031; |
36 | env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F; | 88 | - cpu->id_pfr1 = 0x11; |
37 | 89 | + cpu->isar.id_pfr0 = 0x1031; | |
38 | if (arm_feature(env, ARM_FEATURE_M)) { | 90 | + cpu->isar.id_pfr1 = 0x11; |
91 | cpu->isar.id_dfr0 = 0x400; | ||
92 | cpu->id_afr0 = 0; | ||
93 | cpu->isar.id_mmfr0 = 0x31100003; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | ||
95 | cpu->isar.mvfr1 = 0x01111111; | ||
96 | cpu->ctr = 0x80038003; | ||
97 | cpu->reset_sctlr = 0x00c50078; | ||
98 | - cpu->id_pfr0 = 0x1031; | ||
99 | - cpu->id_pfr1 = 0x11; | ||
100 | + cpu->isar.id_pfr0 = 0x1031; | ||
101 | + cpu->isar.id_pfr1 = 0x11; | ||
102 | cpu->isar.id_dfr0 = 0x000; | ||
103 | cpu->id_afr0 = 0; | ||
104 | cpu->isar.id_mmfr0 = 0x00100103; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
106 | cpu->isar.mvfr1 = 0x11111111; | ||
107 | cpu->ctr = 0x84448003; | ||
108 | cpu->reset_sctlr = 0x00c50078; | ||
109 | - cpu->id_pfr0 = 0x00001131; | ||
110 | - cpu->id_pfr1 = 0x00011011; | ||
111 | + cpu->isar.id_pfr0 = 0x00001131; | ||
112 | + cpu->isar.id_pfr1 = 0x00011011; | ||
113 | cpu->isar.id_dfr0 = 0x02010555; | ||
114 | cpu->id_afr0 = 0x00000000; | ||
115 | cpu->isar.id_mmfr0 = 0x10101105; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
117 | cpu->isar.mvfr1 = 0x11111111; | ||
118 | cpu->ctr = 0x8444c004; | ||
119 | cpu->reset_sctlr = 0x00c50078; | ||
120 | - cpu->id_pfr0 = 0x00001131; | ||
121 | - cpu->id_pfr1 = 0x00011011; | ||
122 | + cpu->isar.id_pfr0 = 0x00001131; | ||
123 | + cpu->isar.id_pfr1 = 0x00011011; | ||
124 | cpu->isar.id_dfr0 = 0x02010555; | ||
125 | cpu->id_afr0 = 0x00000000; | ||
126 | cpu->isar.id_mmfr0 = 0x10201105; | ||
127 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/target/arm/cpu64.c | ||
130 | +++ b/target/arm/cpu64.c | ||
131 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
132 | cpu->isar.mvfr2 = 0x00000043; | ||
133 | cpu->ctr = 0x8444c004; | ||
134 | cpu->reset_sctlr = 0x00c50838; | ||
135 | - cpu->id_pfr0 = 0x00000131; | ||
136 | - cpu->id_pfr1 = 0x00011011; | ||
137 | + cpu->isar.id_pfr0 = 0x00000131; | ||
138 | + cpu->isar.id_pfr1 = 0x00011011; | ||
139 | cpu->isar.id_dfr0 = 0x03010066; | ||
140 | cpu->id_afr0 = 0x00000000; | ||
141 | cpu->isar.id_mmfr0 = 0x10101105; | ||
142 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
143 | cpu->isar.mvfr2 = 0x00000043; | ||
144 | cpu->ctr = 0x84448004; /* L1Ip = VIPT */ | ||
145 | cpu->reset_sctlr = 0x00c50838; | ||
146 | - cpu->id_pfr0 = 0x00000131; | ||
147 | - cpu->id_pfr1 = 0x00011011; | ||
148 | + cpu->isar.id_pfr0 = 0x00000131; | ||
149 | + cpu->isar.id_pfr1 = 0x00011011; | ||
150 | cpu->isar.id_dfr0 = 0x03010066; | ||
151 | cpu->id_afr0 = 0x00000000; | ||
152 | cpu->isar.id_mmfr0 = 0x10101105; | ||
153 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
154 | cpu->isar.mvfr2 = 0x00000043; | ||
155 | cpu->ctr = 0x8444c004; | ||
156 | cpu->reset_sctlr = 0x00c50838; | ||
157 | - cpu->id_pfr0 = 0x00000131; | ||
158 | - cpu->id_pfr1 = 0x00011011; | ||
159 | + cpu->isar.id_pfr0 = 0x00000131; | ||
160 | + cpu->isar.id_pfr1 = 0x00011011; | ||
161 | cpu->isar.id_dfr0 = 0x03010066; | ||
162 | cpu->id_afr0 = 0x00000000; | ||
163 | cpu->isar.id_mmfr0 = 0x10201105; | ||
164 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
165 | index XXXXXXX..XXXXXXX 100644 | ||
166 | --- a/target/arm/cpu_tcg.c | ||
167 | +++ b/target/arm/cpu_tcg.c | ||
168 | @@ -XXX,XX +XXX,XX @@ static void arm1136_r2_initfn(Object *obj) | ||
169 | cpu->isar.mvfr1 = 0x00000000; | ||
170 | cpu->ctr = 0x1dd20d2; | ||
171 | cpu->reset_sctlr = 0x00050078; | ||
172 | - cpu->id_pfr0 = 0x111; | ||
173 | - cpu->id_pfr1 = 0x1; | ||
174 | + cpu->isar.id_pfr0 = 0x111; | ||
175 | + cpu->isar.id_pfr1 = 0x1; | ||
176 | cpu->isar.id_dfr0 = 0x2; | ||
177 | cpu->id_afr0 = 0x3; | ||
178 | cpu->isar.id_mmfr0 = 0x01130003; | ||
179 | @@ -XXX,XX +XXX,XX @@ static void arm1136_initfn(Object *obj) | ||
180 | cpu->isar.mvfr1 = 0x00000000; | ||
181 | cpu->ctr = 0x1dd20d2; | ||
182 | cpu->reset_sctlr = 0x00050078; | ||
183 | - cpu->id_pfr0 = 0x111; | ||
184 | - cpu->id_pfr1 = 0x1; | ||
185 | + cpu->isar.id_pfr0 = 0x111; | ||
186 | + cpu->isar.id_pfr1 = 0x1; | ||
187 | cpu->isar.id_dfr0 = 0x2; | ||
188 | cpu->id_afr0 = 0x3; | ||
189 | cpu->isar.id_mmfr0 = 0x01130003; | ||
190 | @@ -XXX,XX +XXX,XX @@ static void arm1176_initfn(Object *obj) | ||
191 | cpu->isar.mvfr1 = 0x00000000; | ||
192 | cpu->ctr = 0x1dd20d2; | ||
193 | cpu->reset_sctlr = 0x00050078; | ||
194 | - cpu->id_pfr0 = 0x111; | ||
195 | - cpu->id_pfr1 = 0x11; | ||
196 | + cpu->isar.id_pfr0 = 0x111; | ||
197 | + cpu->isar.id_pfr1 = 0x11; | ||
198 | cpu->isar.id_dfr0 = 0x33; | ||
199 | cpu->id_afr0 = 0; | ||
200 | cpu->isar.id_mmfr0 = 0x01130003; | ||
201 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | ||
202 | cpu->isar.mvfr0 = 0x11111111; | ||
203 | cpu->isar.mvfr1 = 0x00000000; | ||
204 | cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ | ||
205 | - cpu->id_pfr0 = 0x111; | ||
206 | - cpu->id_pfr1 = 0x1; | ||
207 | + cpu->isar.id_pfr0 = 0x111; | ||
208 | + cpu->isar.id_pfr1 = 0x1; | ||
209 | cpu->isar.id_dfr0 = 0; | ||
210 | cpu->id_afr0 = 0x2; | ||
211 | cpu->isar.id_mmfr0 = 0x01100103; | ||
212 | @@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj) | ||
213 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
214 | cpu->midr = 0x410fc231; | ||
215 | cpu->pmsav7_dregion = 8; | ||
216 | - cpu->id_pfr0 = 0x00000030; | ||
217 | - cpu->id_pfr1 = 0x00000200; | ||
218 | + cpu->isar.id_pfr0 = 0x00000030; | ||
219 | + cpu->isar.id_pfr1 = 0x00000200; | ||
220 | cpu->isar.id_dfr0 = 0x00100000; | ||
221 | cpu->id_afr0 = 0x00000000; | ||
222 | cpu->isar.id_mmfr0 = 0x00000030; | ||
223 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | ||
224 | cpu->isar.mvfr0 = 0x10110021; | ||
225 | cpu->isar.mvfr1 = 0x11000011; | ||
226 | cpu->isar.mvfr2 = 0x00000000; | ||
227 | - cpu->id_pfr0 = 0x00000030; | ||
228 | - cpu->id_pfr1 = 0x00000200; | ||
229 | + cpu->isar.id_pfr0 = 0x00000030; | ||
230 | + cpu->isar.id_pfr1 = 0x00000200; | ||
231 | cpu->isar.id_dfr0 = 0x00100000; | ||
232 | cpu->id_afr0 = 0x00000000; | ||
233 | cpu->isar.id_mmfr0 = 0x00000030; | ||
234 | @@ -XXX,XX +XXX,XX @@ static void cortex_m7_initfn(Object *obj) | ||
235 | cpu->isar.mvfr0 = 0x10110221; | ||
236 | cpu->isar.mvfr1 = 0x12000011; | ||
237 | cpu->isar.mvfr2 = 0x00000040; | ||
238 | - cpu->id_pfr0 = 0x00000030; | ||
239 | - cpu->id_pfr1 = 0x00000200; | ||
240 | + cpu->isar.id_pfr0 = 0x00000030; | ||
241 | + cpu->isar.id_pfr1 = 0x00000200; | ||
242 | cpu->isar.id_dfr0 = 0x00100000; | ||
243 | cpu->id_afr0 = 0x00000000; | ||
244 | cpu->isar.id_mmfr0 = 0x00100030; | ||
245 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | ||
246 | cpu->isar.mvfr0 = 0x10110021; | ||
247 | cpu->isar.mvfr1 = 0x11000011; | ||
248 | cpu->isar.mvfr2 = 0x00000040; | ||
249 | - cpu->id_pfr0 = 0x00000030; | ||
250 | - cpu->id_pfr1 = 0x00000210; | ||
251 | + cpu->isar.id_pfr0 = 0x00000030; | ||
252 | + cpu->isar.id_pfr1 = 0x00000210; | ||
253 | cpu->isar.id_dfr0 = 0x00200000; | ||
254 | cpu->id_afr0 = 0x00000000; | ||
255 | cpu->isar.id_mmfr0 = 0x00101F40; | ||
256 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
257 | set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
258 | set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
259 | cpu->midr = 0x411fc153; /* r1p3 */ | ||
260 | - cpu->id_pfr0 = 0x0131; | ||
261 | - cpu->id_pfr1 = 0x001; | ||
262 | + cpu->isar.id_pfr0 = 0x0131; | ||
263 | + cpu->isar.id_pfr1 = 0x001; | ||
264 | cpu->isar.id_dfr0 = 0x010400; | ||
265 | cpu->id_afr0 = 0x0; | ||
266 | cpu->isar.id_mmfr0 = 0x0210030; | ||
267 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
268 | index XXXXXXX..XXXXXXX 100644 | ||
269 | --- a/target/arm/helper.c | ||
270 | +++ b/target/arm/helper.c | ||
271 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
272 | static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
273 | { | ||
274 | ARMCPU *cpu = env_archcpu(env); | ||
275 | - uint64_t pfr1 = cpu->id_pfr1; | ||
276 | + uint64_t pfr1 = cpu->isar.id_pfr1; | ||
277 | |||
278 | if (env->gicv3state) { | ||
279 | pfr1 |= 1 << 28; | ||
280 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
281 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0, | ||
282 | .access = PL1_R, .type = ARM_CP_CONST, | ||
283 | .accessfn = access_aa32_tid3, | ||
284 | - .resetvalue = cpu->id_pfr0 }, | ||
285 | + .resetvalue = cpu->isar.id_pfr0 }, | ||
286 | /* ID_PFR1 is not a plain ARM_CP_CONST because we don't know | ||
287 | * the value of the GIC field until after we define these regs. | ||
288 | */ | ||
289 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
290 | index XXXXXXX..XXXXXXX 100644 | ||
291 | --- a/target/arm/kvm64.c | ||
292 | +++ b/target/arm/kvm64.c | ||
293 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
294 | * than skipping the reads and leaving 0, as we must avoid | ||
295 | * considering the values in every case. | ||
296 | */ | ||
297 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, | ||
298 | + ARM64_SYS_REG(3, 0, 0, 1, 0)); | ||
299 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, | ||
300 | + ARM64_SYS_REG(3, 0, 0, 1, 1)); | ||
301 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, | ||
302 | ARM64_SYS_REG(3, 0, 0, 1, 2)); | ||
303 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, | ||
39 | -- | 304 | -- |
40 | 2.19.0 | 305 | 2.20.1 |
41 | 306 | ||
42 | 307 | diff view generated by jsdifflib |
1 | The GIC_BASE_IRQ macro is a leftover from when we shared code | 1 | M-profile CPUs only implement the ID registers as guest-visible if |
---|---|---|---|
2 | between the GICv2 and the v7M NVIC. Since the NVIC is now | 2 | the CPU implements the Main Extension (all our current CPUs except |
3 | split off, GIC_BASE_IRQ is always 0, and we can just delete it. | 3 | the Cortex-M0 do). |
4 | |||
5 | Currently we handle this by having the Cortex-M0 leave the ID | ||
6 | register values in the ARMCPU struct as zero, but this conflicts with | ||
7 | our design decision to make QEMU behaviour be keyed off ID register | ||
8 | fields wherever possible. | ||
9 | |||
10 | Explicitly code the ID registers in the NVIC to return 0 if the Main | ||
11 | Extension is not implemented, so we can make the M0 model set the | ||
12 | ARMCPU struct fields to obtain the correct behaviour without those | ||
13 | values becoming guest-visible. | ||
4 | 14 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 17 | Message-id: 20200910173855.4068-4-peter.maydell@linaro.org |
8 | Message-id: 20180824161819.11085-1-peter.maydell@linaro.org | ||
9 | --- | 18 | --- |
10 | hw/intc/gic_internal.h | 2 -- | 19 | hw/intc/armv7m_nvic.c | 42 ++++++++++++++++++++++++++++++++++++++++++ |
11 | hw/intc/arm_gic.c | 31 ++++++++++++++----------------- | 20 | 1 file changed, 42 insertions(+) |
12 | hw/intc/arm_gic_common.c | 1 - | ||
13 | 3 files changed, 14 insertions(+), 20 deletions(-) | ||
14 | 21 | ||
15 | diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h | 22 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
16 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/intc/gic_internal.h | 24 | --- a/hw/intc/armv7m_nvic.c |
18 | +++ b/hw/intc/gic_internal.h | 25 | +++ b/hw/intc/armv7m_nvic.c |
19 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
20 | 27 | "Aux Fault status registers unimplemented\n"); | |
21 | #define ALL_CPU_MASK ((unsigned)(((1 << GIC_NCPU) - 1))) | 28 | return 0; |
22 | 29 | case 0xd40: /* PFR0. */ | |
23 | -#define GIC_BASE_IRQ 0 | 30 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
24 | - | 31 | + goto bad_offset; |
25 | #define GIC_DIST_SET_ENABLED(irq, cm) (s->irq_state[irq].enabled |= (cm)) | 32 | + } |
26 | #define GIC_DIST_CLEAR_ENABLED(irq, cm) (s->irq_state[irq].enabled &= ~(cm)) | 33 | return cpu->isar.id_pfr0; |
27 | #define GIC_DIST_TEST_ENABLED(irq, cm) ((s->irq_state[irq].enabled & (cm)) != 0) | 34 | case 0xd44: /* PFR1. */ |
28 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | 35 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
29 | index XXXXXXX..XXXXXXX 100644 | 36 | + goto bad_offset; |
30 | --- a/hw/intc/arm_gic.c | 37 | + } |
31 | +++ b/hw/intc/arm_gic.c | 38 | return cpu->isar.id_pfr1; |
32 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 39 | case 0xd48: /* DFR0. */ |
33 | res = 0; | 40 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
34 | if (!(s->security_extn && !attrs.secure) && gic_has_groups(s)) { | 41 | + goto bad_offset; |
35 | /* Every byte offset holds 8 group status bits */ | 42 | + } |
36 | - irq = (offset - 0x080) * 8 + GIC_BASE_IRQ; | 43 | return cpu->isar.id_dfr0; |
37 | + irq = (offset - 0x080) * 8; | 44 | case 0xd4c: /* AFR0. */ |
38 | if (irq >= s->num_irq) { | 45 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
39 | goto bad_reg; | 46 | + goto bad_offset; |
40 | } | 47 | + } |
41 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 48 | return cpu->id_afr0; |
42 | irq = (offset - 0x100) * 8; | 49 | case 0xd50: /* MMFR0. */ |
43 | else | 50 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
44 | irq = (offset - 0x180) * 8; | 51 | + goto bad_offset; |
45 | - irq += GIC_BASE_IRQ; | 52 | + } |
46 | if (irq >= s->num_irq) | 53 | return cpu->isar.id_mmfr0; |
47 | goto bad_reg; | 54 | case 0xd54: /* MMFR1. */ |
48 | res = 0; | 55 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
49 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 56 | + goto bad_offset; |
50 | irq = (offset - 0x200) * 8; | 57 | + } |
51 | else | 58 | return cpu->isar.id_mmfr1; |
52 | irq = (offset - 0x280) * 8; | 59 | case 0xd58: /* MMFR2. */ |
53 | - irq += GIC_BASE_IRQ; | 60 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
54 | if (irq >= s->num_irq) | 61 | + goto bad_offset; |
55 | goto bad_reg; | 62 | + } |
56 | res = 0; | 63 | return cpu->isar.id_mmfr2; |
57 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 64 | case 0xd5c: /* MMFR3. */ |
58 | goto bad_reg; | 65 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
59 | } | 66 | + goto bad_offset; |
60 | 67 | + } | |
61 | - irq += GIC_BASE_IRQ; | 68 | return cpu->isar.id_mmfr3; |
62 | if (irq >= s->num_irq) | 69 | case 0xd60: /* ISAR0. */ |
63 | goto bad_reg; | 70 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
64 | res = 0; | 71 | + goto bad_offset; |
65 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 72 | + } |
66 | } | 73 | return cpu->isar.id_isar0; |
67 | } else if (offset < 0x800) { | 74 | case 0xd64: /* ISAR1. */ |
68 | /* Interrupt Priority. */ | 75 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
69 | - irq = (offset - 0x400) + GIC_BASE_IRQ; | 76 | + goto bad_offset; |
70 | + irq = (offset - 0x400); | 77 | + } |
71 | if (irq >= s->num_irq) | 78 | return cpu->isar.id_isar1; |
72 | goto bad_reg; | 79 | case 0xd68: /* ISAR2. */ |
73 | res = gic_dist_get_priority(s, cpu, irq, attrs); | 80 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
74 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 81 | + goto bad_offset; |
75 | /* For uniprocessor GICs these RAZ/WI */ | 82 | + } |
76 | res = 0; | 83 | return cpu->isar.id_isar2; |
77 | } else { | 84 | case 0xd6c: /* ISAR3. */ |
78 | - irq = (offset - 0x800) + GIC_BASE_IRQ; | 85 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
79 | + irq = (offset - 0x800); | 86 | + goto bad_offset; |
80 | if (irq >= s->num_irq) { | 87 | + } |
81 | goto bad_reg; | 88 | return cpu->isar.id_isar3; |
82 | } | 89 | case 0xd70: /* ISAR4. */ |
83 | @@ -XXX,XX +XXX,XX @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) | 90 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
84 | } | 91 | + goto bad_offset; |
85 | } else if (offset < 0xf00) { | 92 | + } |
86 | /* Interrupt Configuration. */ | 93 | return cpu->isar.id_isar4; |
87 | - irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ; | 94 | case 0xd74: /* ISAR5. */ |
88 | + irq = (offset - 0xc00) * 4; | 95 | + if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
89 | if (irq >= s->num_irq) | 96 | + goto bad_offset; |
90 | goto bad_reg; | 97 | + } |
91 | res = 0; | 98 | return cpu->isar.id_isar5; |
92 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | 99 | case 0xd78: /* CLIDR */ |
93 | */ | 100 | return cpu->clidr; |
94 | if (!(s->security_extn && !attrs.secure) && gic_has_groups(s)) { | ||
95 | /* Every byte offset holds 8 group status bits */ | ||
96 | - irq = (offset - 0x80) * 8 + GIC_BASE_IRQ; | ||
97 | + irq = (offset - 0x80) * 8; | ||
98 | if (irq >= s->num_irq) { | ||
99 | goto bad_reg; | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
102 | } | ||
103 | } else if (offset < 0x180) { | ||
104 | /* Interrupt Set Enable. */ | ||
105 | - irq = (offset - 0x100) * 8 + GIC_BASE_IRQ; | ||
106 | + irq = (offset - 0x100) * 8; | ||
107 | if (irq >= s->num_irq) | ||
108 | goto bad_reg; | ||
109 | if (irq < GIC_NR_SGIS) { | ||
110 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
111 | } | ||
112 | } else if (offset < 0x200) { | ||
113 | /* Interrupt Clear Enable. */ | ||
114 | - irq = (offset - 0x180) * 8 + GIC_BASE_IRQ; | ||
115 | + irq = (offset - 0x180) * 8; | ||
116 | if (irq >= s->num_irq) | ||
117 | goto bad_reg; | ||
118 | if (irq < GIC_NR_SGIS) { | ||
119 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
120 | } | ||
121 | } else if (offset < 0x280) { | ||
122 | /* Interrupt Set Pending. */ | ||
123 | - irq = (offset - 0x200) * 8 + GIC_BASE_IRQ; | ||
124 | + irq = (offset - 0x200) * 8; | ||
125 | if (irq >= s->num_irq) | ||
126 | goto bad_reg; | ||
127 | if (irq < GIC_NR_SGIS) { | ||
128 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
129 | } | ||
130 | } else if (offset < 0x300) { | ||
131 | /* Interrupt Clear Pending. */ | ||
132 | - irq = (offset - 0x280) * 8 + GIC_BASE_IRQ; | ||
133 | + irq = (offset - 0x280) * 8; | ||
134 | if (irq >= s->num_irq) | ||
135 | goto bad_reg; | ||
136 | if (irq < GIC_NR_SGIS) { | ||
137 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
138 | goto bad_reg; | ||
139 | } | ||
140 | |||
141 | - irq = (offset - 0x300) * 8 + GIC_BASE_IRQ; | ||
142 | + irq = (offset - 0x300) * 8; | ||
143 | if (irq >= s->num_irq) { | ||
144 | goto bad_reg; | ||
145 | } | ||
146 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
147 | goto bad_reg; | ||
148 | } | ||
149 | |||
150 | - irq = (offset - 0x380) * 8 + GIC_BASE_IRQ; | ||
151 | + irq = (offset - 0x380) * 8; | ||
152 | if (irq >= s->num_irq) { | ||
153 | goto bad_reg; | ||
154 | } | ||
155 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
156 | } | ||
157 | } else if (offset < 0x800) { | ||
158 | /* Interrupt Priority. */ | ||
159 | - irq = (offset - 0x400) + GIC_BASE_IRQ; | ||
160 | + irq = (offset - 0x400); | ||
161 | if (irq >= s->num_irq) | ||
162 | goto bad_reg; | ||
163 | gic_dist_set_priority(s, cpu, irq, value, attrs); | ||
164 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
165 | * annoying exception of the 11MPCore's GIC. | ||
166 | */ | ||
167 | if (s->num_cpu != 1 || s->revision == REV_11MPCORE) { | ||
168 | - irq = (offset - 0x800) + GIC_BASE_IRQ; | ||
169 | + irq = (offset - 0x800); | ||
170 | if (irq >= s->num_irq) { | ||
171 | goto bad_reg; | ||
172 | } | ||
173 | @@ -XXX,XX +XXX,XX @@ static void gic_dist_writeb(void *opaque, hwaddr offset, | ||
174 | } | ||
175 | } else if (offset < 0xf00) { | ||
176 | /* Interrupt Configuration. */ | ||
177 | - irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ; | ||
178 | + irq = (offset - 0xc00) * 4; | ||
179 | if (irq >= s->num_irq) | ||
180 | goto bad_reg; | ||
181 | if (irq < GIC_NR_SGIS) | ||
182 | diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c | ||
183 | index XXXXXXX..XXXXXXX 100644 | ||
184 | --- a/hw/intc/arm_gic_common.c | ||
185 | +++ b/hw/intc/arm_gic_common.c | ||
186 | @@ -XXX,XX +XXX,XX @@ static void arm_gic_common_realize(DeviceState *dev, Error **errp) | ||
187 | s->num_cpu, GIC_NCPU); | ||
188 | return; | ||
189 | } | ||
190 | - s->num_irq += GIC_BASE_IRQ; | ||
191 | if (s->num_irq > GIC_MAXIRQ) { | ||
192 | error_setg(errp, | ||
193 | "requested %u interrupt lines exceeds GIC maximum %d", | ||
194 | -- | 101 | -- |
195 | 2.19.0 | 102 | 2.20.1 |
196 | 103 | ||
197 | 104 | diff view generated by jsdifflib |
1 | The GICv2's QEMU interface (sysbus MMIO regions, IRQs, | 1 | Give the Cortex-M0 ID register values corresponding to its |
---|---|---|---|
2 | etc) is now quite complicated with the addition of the | 2 | implemented behaviour. These will not be guest-visible but will be |
3 | virtualization extensions. Add a comment in the header | 3 | used to govern the behaviour of QEMU's emulation. We use the same |
4 | file which documents it. | 4 | values that the Cortex-M3 does. |
5 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20180823103818.31189-1-peter.maydell@linaro.org | 8 | Message-id: 20200910173855.4068-5-peter.maydell@linaro.org |
9 | --- | 9 | --- |
10 | include/hw/intc/arm_gic.h | 43 +++++++++++++++++++++++++++++++++++++++ | 10 | target/arm/cpu_tcg.c | 24 ++++++++++++++++++++++++ |
11 | 1 file changed, 43 insertions(+) | 11 | 1 file changed, 24 insertions(+) |
12 | 12 | ||
13 | diff --git a/include/hw/intc/arm_gic.h b/include/hw/intc/arm_gic.h | 13 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/intc/arm_gic.h | 15 | --- a/target/arm/cpu_tcg.c |
16 | +++ b/include/hw/intc/arm_gic.h | 16 | +++ b/target/arm/cpu_tcg.c |
17 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static void cortex_m0_initfn(Object *obj) |
18 | * with this program; if not, see <http://www.gnu.org/licenses/>. | 18 | set_feature(&cpu->env, ARM_FEATURE_M); |
19 | */ | 19 | |
20 | 20 | cpu->midr = 0x410cc200; | |
21 | +/* | ||
22 | + * QEMU interface: | ||
23 | + * + QOM property "num-cpu": number of CPUs to support | ||
24 | + * + QOM property "num-irq": number of IRQs (including both SPIs and PPIs) | ||
25 | + * + QOM property "revision": GIC version (1 or 2), or 0 for the 11MPCore GIC | ||
26 | + * + QOM property "has-security-extensions": set true if the GIC should | ||
27 | + * implement the security extensions | ||
28 | + * + QOM property "has-virtualization-extensions": set true if the GIC should | ||
29 | + * implement the virtualization extensions | ||
30 | + * + unnamed GPIO inputs: (where P is number of SPIs, i.e. num-irq - 32) | ||
31 | + * [0..P-1] SPIs | ||
32 | + * [P..P+31] PPIs for CPU 0 | ||
33 | + * [P+32..P+63] PPIs for CPU 1 | ||
34 | + * ... | ||
35 | + * + sysbus IRQs: (in order; number will vary depending on number of cores) | ||
36 | + * - IRQ for CPU 0 | ||
37 | + * - IRQ for CPU 1 | ||
38 | + * ... | ||
39 | + * - FIQ for CPU 0 | ||
40 | + * - FIQ for CPU 1 | ||
41 | + * ... | ||
42 | + * - VIRQ for CPU 0 (exists even if virt extensions not present) | ||
43 | + * - VIRQ for CPU 1 (exists even if virt extensions not present) | ||
44 | + * ... | ||
45 | + * - VFIQ for CPU 0 (exists even if virt extensions not present) | ||
46 | + * - VFIQ for CPU 1 (exists even if virt extensions not present) | ||
47 | + * ... | ||
48 | + * - maintenance IRQ for CPU i/f 0 (only if virt extensions present) | ||
49 | + * - maintenance IRQ for CPU i/f 1 (only if virt extensions present) | ||
50 | + * + sysbus MMIO regions: (in order; numbers will vary depending on | ||
51 | + * whether virtualization extensions are present and on number of cores) | ||
52 | + * - distributor registers (GICD*) | ||
53 | + * - CPU interface for the accessing core (GICC*) | ||
54 | + * - virtual interface control registers (GICH*) (only if virt extns present) | ||
55 | + * - virtual CPU interface for the accessing core (GICV*) (only if virt) | ||
56 | + * - CPU 0 CPU interface registers | ||
57 | + * - CPU 1 CPU interface registers | ||
58 | + * ... | ||
59 | + * - CPU 0 virtual interface control registers (only if virt extns present) | ||
60 | + * - CPU 1 virtual interface control registers (only if virt extns present) | ||
61 | + * ... | ||
62 | + */ | ||
63 | + | 21 | + |
64 | #ifndef HW_ARM_GIC_H | 22 | + /* |
65 | #define HW_ARM_GIC_H | 23 | + * These ID register values are not guest visible, because |
66 | 24 | + * we do not implement the Main Extension. They must be set | |
25 | + * to values corresponding to the Cortex-M0's implemented | ||
26 | + * features, because QEMU generally controls its emulation | ||
27 | + * by looking at ID register fields. We use the same values as | ||
28 | + * for the M3. | ||
29 | + */ | ||
30 | + cpu->isar.id_pfr0 = 0x00000030; | ||
31 | + cpu->isar.id_pfr1 = 0x00000200; | ||
32 | + cpu->isar.id_dfr0 = 0x00100000; | ||
33 | + cpu->id_afr0 = 0x00000000; | ||
34 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
35 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
36 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
37 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
38 | + cpu->isar.id_isar0 = 0x01141110; | ||
39 | + cpu->isar.id_isar1 = 0x02111000; | ||
40 | + cpu->isar.id_isar2 = 0x21112231; | ||
41 | + cpu->isar.id_isar3 = 0x01111110; | ||
42 | + cpu->isar.id_isar4 = 0x01310102; | ||
43 | + cpu->isar.id_isar5 = 0x00000000; | ||
44 | + cpu->isar.id_isar6 = 0x00000000; | ||
45 | } | ||
46 | |||
47 | static void cortex_m3_initfn(Object *obj) | ||
67 | -- | 48 | -- |
68 | 2.19.0 | 49 | 2.20.1 |
69 | 50 | ||
70 | 51 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | The M-profile definition of the MVFR1 ID register differs slightly |
---|---|---|---|
2 | from the A-profile one, and in particular the check for "does the CPU | ||
3 | support fp16 arithmetic" is not the same. | ||
2 | 4 | ||
3 | Receive command handling may have to be deferred if a previous receive | 5 | We don't currently implement any M-profile CPUs with fp16 arithmetic, |
4 | done interrupt was not yet acknowledged. Move receive command handling | 6 | so this is not yet a visible bug, but correcting the logic now |
5 | into a separate function to prepare for the necessary changes. | 7 | disarms this beartrap for when we eventually do. |
6 | 8 | ||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20180914063506.20815-3-clg@kaod.org | ||
10 | 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> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20200910173855.4068-6-peter.maydell@linaro.org | ||
12 | --- | 12 | --- |
13 | hw/i2c/aspeed_i2c.c | 37 +++++++++++++++++++++---------------- | 13 | target/arm/cpu.h | 31 ++++++++++++++++++++++++++----- |
14 | 1 file changed, 21 insertions(+), 16 deletions(-) | 14 | 1 file changed, 26 insertions(+), 5 deletions(-) |
15 | 15 | ||
16 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/i2c/aspeed_i2c.c | 18 | --- a/target/arm/cpu.h |
19 | +++ b/hw/i2c/aspeed_i2c.c | 19 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_state(AspeedI2CBus *bus) | 20 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, LSM, 20, 4) |
21 | return (bus->cmd >> I2CD_TX_STATE_SHIFT) & I2CD_TX_STATE_MASK; | 21 | FIELD(ID_MMFR4, CCIDX, 24, 4) |
22 | FIELD(ID_MMFR4, EVT, 28, 4) | ||
23 | |||
24 | +FIELD(ID_PFR1, PROGMOD, 0, 4) | ||
25 | +FIELD(ID_PFR1, SECURITY, 4, 4) | ||
26 | +FIELD(ID_PFR1, MPROGMOD, 8, 4) | ||
27 | +FIELD(ID_PFR1, VIRTUALIZATION, 12, 4) | ||
28 | +FIELD(ID_PFR1, GENTIMER, 16, 4) | ||
29 | +FIELD(ID_PFR1, SEC_FRAC, 20, 4) | ||
30 | +FIELD(ID_PFR1, VIRT_FRAC, 24, 4) | ||
31 | +FIELD(ID_PFR1, GIC, 28, 4) | ||
32 | + | ||
33 | FIELD(ID_AA64ISAR0, AES, 4, 4) | ||
34 | FIELD(ID_AA64ISAR0, SHA1, 8, 4) | ||
35 | FIELD(ID_AA64ISAR0, SHA2, 12, 4) | ||
36 | @@ -XXX,XX +XXX,XX @@ FIELD(MVFR0, FPROUND, 28, 4) | ||
37 | |||
38 | FIELD(MVFR1, FPFTZ, 0, 4) | ||
39 | FIELD(MVFR1, FPDNAN, 4, 4) | ||
40 | -FIELD(MVFR1, SIMDLS, 8, 4) | ||
41 | -FIELD(MVFR1, SIMDINT, 12, 4) | ||
42 | -FIELD(MVFR1, SIMDSP, 16, 4) | ||
43 | -FIELD(MVFR1, SIMDHP, 20, 4) | ||
44 | +FIELD(MVFR1, SIMDLS, 8, 4) /* A-profile only */ | ||
45 | +FIELD(MVFR1, SIMDINT, 12, 4) /* A-profile only */ | ||
46 | +FIELD(MVFR1, SIMDSP, 16, 4) /* A-profile only */ | ||
47 | +FIELD(MVFR1, SIMDHP, 20, 4) /* A-profile only */ | ||
48 | +FIELD(MVFR1, MVE, 8, 4) /* M-profile only */ | ||
49 | +FIELD(MVFR1, FP16, 20, 4) /* M-profile only */ | ||
50 | FIELD(MVFR1, FPHP, 24, 4) | ||
51 | FIELD(MVFR1, SIMDFMAC, 28, 4) | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) | ||
54 | return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; | ||
22 | } | 55 | } |
23 | 56 | ||
24 | +static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus) | 57 | +static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) |
25 | +{ | 58 | +{ |
26 | + int ret; | 59 | + return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; |
27 | + | ||
28 | + aspeed_i2c_set_state(bus, I2CD_MRXD); | ||
29 | + ret = i2c_recv(bus->bus); | ||
30 | + if (ret < 0) { | ||
31 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: read failed\n", __func__); | ||
32 | + ret = 0xff; | ||
33 | + } else { | ||
34 | + bus->intr_status |= I2CD_INTR_RX_DONE; | ||
35 | + } | ||
36 | + bus->buf = (ret & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
37 | + if (bus->cmd & I2CD_M_S_RX_CMD_LAST) { | ||
38 | + i2c_nack(bus->bus); | ||
39 | + } | ||
40 | + bus->cmd &= ~(I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST); | ||
41 | + aspeed_i2c_set_state(bus, I2CD_MACTIVE); | ||
42 | +} | 60 | +} |
43 | + | 61 | + |
44 | /* | 62 | static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) |
45 | * The state machine needs some refinement. It is only used to track | 63 | { |
46 | * invalid STOP commands for the moment. | 64 | - return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3; |
47 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | 65 | + /* Sadly this is encoded differently for A-profile and M-profile */ |
48 | } | 66 | + if (isar_feature_aa32_mprofile(id)) { |
49 | 67 | + return FIELD_EX32(id->mvfr1, MVFR1, FP16) > 0; | |
50 | if (bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST)) { | 68 | + } else { |
51 | - int ret; | 69 | + return FIELD_EX32(id->mvfr1, MVFR1, FPHP) >= 3; |
52 | - | 70 | + } |
53 | - aspeed_i2c_set_state(bus, I2CD_MRXD); | 71 | } |
54 | - ret = i2c_recv(bus->bus); | 72 | |
55 | - if (ret < 0) { | 73 | static inline bool isar_feature_aa32_vfp_simd(const ARMISARegisters *id) |
56 | - qemu_log_mask(LOG_GUEST_ERROR, "%s: read failed\n", __func__); | ||
57 | - ret = 0xff; | ||
58 | - } else { | ||
59 | - bus->intr_status |= I2CD_INTR_RX_DONE; | ||
60 | - } | ||
61 | - bus->buf = (ret & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
62 | - if (bus->cmd & I2CD_M_S_RX_CMD_LAST) { | ||
63 | - i2c_nack(bus->bus); | ||
64 | - } | ||
65 | - bus->cmd &= ~(I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST); | ||
66 | - aspeed_i2c_set_state(bus, I2CD_MACTIVE); | ||
67 | + aspeed_i2c_handle_rx_cmd(bus); | ||
68 | } | ||
69 | |||
70 | if (bus->cmd & I2CD_M_STOP_CMD) { | ||
71 | -- | 74 | -- |
72 | 2.19.0 | 75 | 2.20.1 |
73 | 76 | ||
74 | 77 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In file included from /home/thuth/devel/qemu/hw/timer/aspeed_timer.c:16: | 3 | The mte update missed a bit when producing clean addresses. |
4 | /home/thuth/devel/qemu/include/hw/misc/aspeed_scu.h:37:3: error: | ||
5 | redefinition of typedef 'AspeedSCUState' is a C11 feature | ||
6 | [-Werror,-Wtypedef-redefinition] | ||
7 | } AspeedSCUState; | ||
8 | ^ | ||
9 | /home/thuth/devel/qemu/include/hw/timer/aspeed_timer.h:27:31: note: | ||
10 | previous definition is here | ||
11 | typedef struct AspeedSCUState AspeedSCUState; | ||
12 | 4 | ||
13 | Reported-by: Thomas Huth <thuth@redhat.com> | 5 | Fixes: b2aa8879b88 |
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20200916014102.2446323-1-richard.henderson@linaro.org |
16 | Message-id: 20180921161939.822-2-clg@kaod.org | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | include/hw/timer/aspeed_timer.h | 3 +-- | 11 | target/arm/translate-sve.c | 4 ++-- |
21 | hw/timer/aspeed_timer.c | 1 - | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
22 | 2 files changed, 1 insertion(+), 3 deletions(-) | ||
23 | 13 | ||
24 | diff --git a/include/hw/timer/aspeed_timer.h b/include/hw/timer/aspeed_timer.h | 14 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
25 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/timer/aspeed_timer.h | 16 | --- a/target/arm/translate-sve.c |
27 | +++ b/include/hw/timer/aspeed_timer.h | 17 | +++ b/target/arm/translate-sve.c |
28 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) |
29 | #define ASPEED_TIMER_H | 19 | for (i = 0; i < len_align; i += 8) { |
30 | 20 | tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEQ); | |
31 | #include "qemu/timer.h" | 21 | tcg_gen_st_i64(t0, cpu_env, vofs + i); |
32 | - | 22 | - tcg_gen_addi_i64(clean_addr, cpu_reg_sp(s, rn), 8); |
33 | -typedef struct AspeedSCUState AspeedSCUState; | 23 | + tcg_gen_addi_i64(clean_addr, clean_addr, 8); |
34 | +#include "hw/misc/aspeed_scu.h" | 24 | } |
35 | 25 | tcg_temp_free_i64(t0); | |
36 | #define ASPEED_TIMER(obj) \ | 26 | } else { |
37 | OBJECT_CHECK(AspeedTimerCtrlState, (obj), TYPE_ASPEED_TIMER); | 27 | @@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) |
38 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | 28 | for (i = 0; i < len_align; i += 8) { |
39 | index XXXXXXX..XXXXXXX 100644 | 29 | tcg_gen_ld_i64(t0, cpu_env, vofs + i); |
40 | --- a/hw/timer/aspeed_timer.c | 30 | tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEQ); |
41 | +++ b/hw/timer/aspeed_timer.c | 31 | - tcg_gen_addi_i64(clean_addr, cpu_reg_sp(s, rn), 8); |
42 | @@ -XXX,XX +XXX,XX @@ | 32 | + tcg_gen_addi_i64(clean_addr, clean_addr, 8); |
43 | #include "qapi/error.h" | 33 | } |
44 | #include "hw/sysbus.h" | 34 | tcg_temp_free_i64(t0); |
45 | #include "hw/timer/aspeed_timer.h" | 35 | } else { |
46 | -#include "hw/misc/aspeed_scu.h" | ||
47 | #include "qemu-common.h" | ||
48 | #include "qemu/bitops.h" | ||
49 | #include "qemu/timer.h" | ||
50 | -- | 36 | -- |
51 | 2.19.0 | 37 | 2.20.1 |
52 | 38 | ||
53 | 39 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The AST2500 evb is shipped with a W25Q256 which has a non volatile bit | 3 | While converting to gen_gvec_ool_zzzp, we lost passing |
4 | to make the chip operate in 4 Byte address mode at power up. This | 4 | a->esz as the data argument to the function. |
5 | should be an interesting feature to model as it will exercise a bit | ||
6 | more the SMC controllers and MMIO execution at boot time. | ||
7 | 5 | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | Fixes: 36cbb7a8e71 |
9 | Message-id: 20180921161939.822-3-clg@kaod.org | 7 | Cc: qemu-stable@nongnu.org |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200918000500.2690937-1-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | hw/arm/aspeed.c | 2 +- | 13 | target/arm/translate-sve.c | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 15 | ||
16 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 16 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/aspeed.c | 18 | --- a/target/arm/translate-sve.c |
19 | +++ b/hw/arm/aspeed.c | 19 | +++ b/target/arm/translate-sve.c |
20 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | 20 | @@ -XXX,XX +XXX,XX @@ static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a) |
21 | [AST2500_EVB] = { | 21 | { |
22 | .soc_name = "ast2500-a1", | 22 | if (sve_access_check(s)) { |
23 | .hw_strap1 = AST2500_EVB_HW_STRAP1, | 23 | gen_gvec_ool_zzzp(s, gen_helper_sve_splice, |
24 | - .fmc_model = "n25q256a", | 24 | - a->rd, a->rn, a->rm, a->pg, 0); |
25 | + .fmc_model = "w25q256", | 25 | + a->rd, a->rn, a->rm, a->pg, a->esz); |
26 | .spi_model = "mx25l25635e", | 26 | } |
27 | .num_cs = 1, | 27 | return true; |
28 | .i2c_init = ast2500_evb_i2c_init, | 28 | } |
29 | -- | 29 | -- |
30 | 2.19.0 | 30 | 2.20.1 |
31 | 31 | ||
32 | 32 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The nRF51 is a Cortex-M0 microcontroller with an on-board radio module, | 3 | The Raspberry firmware is closed-source. While running it, it |
4 | plus other common ARM SoC peripherals. | 4 | accesses various I/O registers. Logging these accesses as UNIMP |
5 | (unimplemented) help to understand what the firmware is doing | ||
6 | (ideally we want it able to boot a Linux kernel). | ||
5 | 7 | ||
6 | http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.pdf | 8 | Document various blocks we might use later. |
7 | 9 | ||
8 | This defines a basic model of the CPU and memory, with no peripherals | 10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
9 | implemented at this stage. | 11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | 12 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | |
11 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 13 | Message-id: 20200921034729.432931-2-f4bug@amsat.org |
12 | Message-id: 20180831220920.27113-3-joel@jms.id.au | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | [PMM: wrapped a few long lines] | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 15 | --- |
17 | hw/arm/Makefile.objs | 1 + | 16 | include/hw/arm/raspi_platform.h | 51 +++++++++++++++++++++++++++------ |
18 | include/hw/arm/nrf51_soc.h | 41 ++++++++++ | 17 | 1 file changed, 43 insertions(+), 8 deletions(-) |
19 | hw/arm/nrf51_soc.c | 133 ++++++++++++++++++++++++++++++++ | ||
20 | default-configs/arm-softmmu.mak | 1 + | ||
21 | 4 files changed, 176 insertions(+) | ||
22 | create mode 100644 include/hw/arm/nrf51_soc.h | ||
23 | create mode 100644 hw/arm/nrf51_soc.c | ||
24 | 18 | ||
25 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 19 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h |
26 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/Makefile.objs | 21 | --- a/include/hw/arm/raspi_platform.h |
28 | +++ b/hw/arm/Makefile.objs | 22 | +++ b/include/hw/arm/raspi_platform.h |
29 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_IOTKIT) += iotkit.o | ||
30 | obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o | ||
31 | obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o | ||
32 | obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.o | ||
33 | +obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o | ||
34 | diff --git a/include/hw/arm/nrf51_soc.h b/include/hw/arm/nrf51_soc.h | ||
35 | new file mode 100644 | ||
36 | index XXXXXXX..XXXXXXX | ||
37 | --- /dev/null | ||
38 | +++ b/include/hw/arm/nrf51_soc.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
40 | +/* | 24 | * You should have received a copy of the GNU General Public License |
41 | + * Nordic Semiconductor nRF51 SoC | 25 | * along with this program; if not, write to the Free Software |
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
42 | + * | 27 | + * |
43 | + * Copyright 2018 Joel Stanley <joel@jms.id.au> | 28 | + * Various undocumented addresses and names come from Herman Hermitage's VC4 |
44 | + * | 29 | + * documentation: |
45 | + * This code is licensed under the GPL version 2 or later. See | 30 | + * https://github.com/hermanhermitage/videocoreiv/wiki/MMIO-Register-map |
46 | + * the COPYING file in the top-level directory. | 31 | */ |
47 | + */ | 32 | |
48 | + | 33 | #ifndef HW_ARM_RASPI_PLATFORM_H |
49 | +#ifndef NRF51_SOC_H | 34 | #define HW_ARM_RASPI_PLATFORM_H |
50 | +#define NRF51_SOC_H | 35 | |
51 | + | 36 | #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ |
52 | +#include "hw/sysbus.h" | 37 | -#define IC0_OFFSET 0x2000 |
53 | +#include "hw/arm/armv7m.h" | 38 | +#define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ |
54 | + | 39 | +#define INTE_OFFSET 0x2000 /* VC Interrupt controller */ |
55 | +#define TYPE_NRF51_SOC "nrf51-soc" | 40 | #define ST_OFFSET 0x3000 /* System Timer */ |
56 | +#define NRF51_SOC(obj) \ | 41 | +#define TXP_OFFSET 0x4000 /* Transposer */ |
57 | + OBJECT_CHECK(NRF51State, (obj), TYPE_NRF51_SOC) | 42 | +#define JPEG_OFFSET 0x5000 |
58 | + | 43 | #define MPHI_OFFSET 0x6000 /* Message-based Parallel Host Intf. */ |
59 | +typedef struct NRF51State { | 44 | #define DMA_OFFSET 0x7000 /* DMA controller, channels 0-14 */ |
60 | + /*< private >*/ | 45 | -#define ARM_OFFSET 0xB000 /* BCM2708 ARM control block */ |
61 | + SysBusDevice parent_obj; | 46 | +#define ARBA_OFFSET 0x9000 |
62 | + | 47 | +#define BRDG_OFFSET 0xa000 |
63 | + /*< public >*/ | 48 | +#define ARM_OFFSET 0xB000 /* ARM control block */ |
64 | + ARMv7MState cpu; | 49 | #define ARMCTRL_OFFSET (ARM_OFFSET + 0x000) |
65 | + | 50 | #define ARMCTRL_IC_OFFSET (ARM_OFFSET + 0x200) /* Interrupt controller */ |
66 | + MemoryRegion iomem; | 51 | -#define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 */ |
67 | + MemoryRegion sram; | 52 | +#define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 (SP804) */ |
68 | + MemoryRegion flash; | 53 | #define ARMCTRL_0_SBM_OFFSET (ARM_OFFSET + 0x800) /* User 0 (ARM) Semaphores |
69 | + | 54 | * Doorbells & Mailboxes */ |
70 | + uint32_t sram_size; | 55 | #define CPRMAN_OFFSET 0x100000 /* Power Management, Watchdog */ |
71 | + uint32_t flash_size; | ||
72 | + | ||
73 | + MemoryRegion *board_memory; | ||
74 | + | ||
75 | + MemoryRegion container; | ||
76 | + | ||
77 | +} NRF51State; | ||
78 | + | ||
79 | +#endif | ||
80 | + | ||
81 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | ||
82 | new file mode 100644 | ||
83 | index XXXXXXX..XXXXXXX | ||
84 | --- /dev/null | ||
85 | +++ b/hw/arm/nrf51_soc.c | ||
86 | @@ -XXX,XX +XXX,XX @@ | 56 | @@ -XXX,XX +XXX,XX @@ |
87 | +/* | 57 | #define AVS_OFFSET 0x103000 /* Audio Video Standard */ |
88 | + * Nordic Semiconductor nRF51 SoC | 58 | #define RNG_OFFSET 0x104000 |
89 | + * http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.1.pdf | 59 | #define GPIO_OFFSET 0x200000 |
90 | + * | 60 | -#define UART0_OFFSET 0x201000 |
91 | + * Copyright 2018 Joel Stanley <joel@jms.id.au> | 61 | -#define MMCI0_OFFSET 0x202000 |
92 | + * | 62 | -#define I2S_OFFSET 0x203000 |
93 | + * This code is licensed under the GPL version 2 or later. See | 63 | -#define SPI0_OFFSET 0x204000 |
94 | + * the COPYING file in the top-level directory. | 64 | +#define UART0_OFFSET 0x201000 /* PL011 */ |
95 | + */ | 65 | +#define MMCI0_OFFSET 0x202000 /* Legacy MMC */ |
96 | + | 66 | +#define I2S_OFFSET 0x203000 /* PCM */ |
97 | +#include "qemu/osdep.h" | 67 | +#define SPI0_OFFSET 0x204000 /* SPI master */ |
98 | +#include "qapi/error.h" | 68 | #define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */ |
99 | +#include "qemu-common.h" | 69 | +#define PIXV0_OFFSET 0x206000 |
100 | +#include "hw/arm/arm.h" | 70 | +#define PIXV1_OFFSET 0x207000 |
101 | +#include "hw/sysbus.h" | 71 | +#define DPI_OFFSET 0x208000 |
102 | +#include "hw/boards.h" | 72 | +#define DSI0_OFFSET 0x209000 /* Display Serial Interface */ |
103 | +#include "hw/devices.h" | 73 | +#define PWM_OFFSET 0x20c000 |
104 | +#include "hw/misc/unimp.h" | 74 | +#define PERM_OFFSET 0x20d000 |
105 | +#include "exec/address-spaces.h" | 75 | +#define TEC_OFFSET 0x20e000 |
106 | +#include "sysemu/sysemu.h" | 76 | #define OTP_OFFSET 0x20f000 |
107 | +#include "qemu/log.h" | 77 | +#define SLIM_OFFSET 0x210000 /* SLIMbus */ |
108 | +#include "cpu.h" | 78 | +#define CPG_OFFSET 0x211000 |
109 | + | 79 | #define THERMAL_OFFSET 0x212000 |
110 | +#include "hw/arm/nrf51_soc.h" | 80 | -#define BSC_SL_OFFSET 0x214000 /* SPI slave */ |
111 | + | 81 | +#define AVSP_OFFSET 0x213000 |
112 | +#define IOMEM_BASE 0x40000000 | 82 | +#define BSC_SL_OFFSET 0x214000 /* SPI slave (bootrom) */ |
113 | +#define IOMEM_SIZE 0x20000000 | 83 | #define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */ |
114 | + | 84 | #define EMMC1_OFFSET 0x300000 |
115 | +#define FICR_BASE 0x10000000 | 85 | +#define EMMC2_OFFSET 0x340000 |
116 | +#define FICR_SIZE 0x000000fc | 86 | +#define HVS_OFFSET 0x400000 |
117 | + | 87 | #define SMI_OFFSET 0x600000 |
118 | +#define FLASH_BASE 0x00000000 | 88 | +#define DSI1_OFFSET 0x700000 |
119 | +#define SRAM_BASE 0x20000000 | 89 | +#define UCAM_OFFSET 0x800000 |
120 | + | 90 | +#define CMI_OFFSET 0x802000 |
121 | +#define PRIVATE_BASE 0xF0000000 | 91 | #define BSC1_OFFSET 0x804000 /* BSC1 I2C/TWI */ |
122 | +#define PRIVATE_SIZE 0x10000000 | 92 | #define BSC2_OFFSET 0x805000 /* BSC2 I2C/TWI */ |
123 | + | 93 | +#define VECA_OFFSET 0x806000 |
124 | +/* | 94 | +#define PIXV2_OFFSET 0x807000 |
125 | + * The size and base is for the NRF51822 part. If other parts | 95 | +#define HDMI_OFFSET 0x808000 |
126 | + * are supported in the future, add a sub-class of NRF51SoC for | 96 | +#define HDCP_OFFSET 0x809000 |
127 | + * the specific variants | 97 | +#define ARBR0_OFFSET 0x80a000 |
128 | + */ | 98 | #define DBUS_OFFSET 0x900000 |
129 | +#define NRF51822_FLASH_SIZE (256 * 1024) | 99 | #define AVE0_OFFSET 0x910000 |
130 | +#define NRF51822_SRAM_SIZE (16 * 1024) | 100 | #define USB_OTG_OFFSET 0x980000 /* DTC_OTG USB controller */ |
131 | + | 101 | +#define V3D_OFFSET 0xc00000 |
132 | +static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | 102 | #define SDRAMC_OFFSET 0xe00000 |
133 | +{ | 103 | +#define L2CC_OFFSET 0xe01000 /* Level 2 Cache controller */ |
134 | + NRF51State *s = NRF51_SOC(dev_soc); | 104 | +#define L1CC_OFFSET 0xe02000 /* Level 1 Cache controller */ |
135 | + Error *err = NULL; | 105 | +#define ARBR1_OFFSET 0xe04000 |
136 | + | 106 | #define DMA15_OFFSET 0xE05000 /* DMA controller, channel 15 */ |
137 | + if (!s->board_memory) { | 107 | +#define DCRC_OFFSET 0xe07000 |
138 | + error_setg(errp, "memory property was not set"); | 108 | +#define AXIP_OFFSET 0xe08000 |
139 | + return; | 109 | |
140 | + } | 110 | /* GPU interrupts */ |
141 | + | 111 | #define INTERRUPT_TIMER0 0 |
142 | + object_property_set_link(OBJECT(&s->cpu), OBJECT(&s->container), "memory", | ||
143 | + &err); | ||
144 | + if (err) { | ||
145 | + error_propagate(errp, err); | ||
146 | + return; | ||
147 | + } | ||
148 | + object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | ||
149 | + if (err) { | ||
150 | + error_propagate(errp, err); | ||
151 | + return; | ||
152 | + } | ||
153 | + | ||
154 | + memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1); | ||
155 | + | ||
156 | + memory_region_init_rom(&s->flash, OBJECT(s), "nrf51.flash", s->flash_size, | ||
157 | + &err); | ||
158 | + if (err) { | ||
159 | + error_propagate(errp, err); | ||
160 | + return; | ||
161 | + } | ||
162 | + memory_region_add_subregion(&s->container, FLASH_BASE, &s->flash); | ||
163 | + | ||
164 | + memory_region_init_ram(&s->sram, NULL, "nrf51.sram", s->sram_size, &err); | ||
165 | + if (err) { | ||
166 | + error_propagate(errp, err); | ||
167 | + return; | ||
168 | + } | ||
169 | + memory_region_add_subregion(&s->container, SRAM_BASE, &s->sram); | ||
170 | + | ||
171 | + create_unimplemented_device("nrf51_soc.io", IOMEM_BASE, IOMEM_SIZE); | ||
172 | + create_unimplemented_device("nrf51_soc.ficr", FICR_BASE, FICR_SIZE); | ||
173 | + create_unimplemented_device("nrf51_soc.private", | ||
174 | + PRIVATE_BASE, PRIVATE_SIZE); | ||
175 | +} | ||
176 | + | ||
177 | +static void nrf51_soc_init(Object *obj) | ||
178 | +{ | ||
179 | + NRF51State *s = NRF51_SOC(obj); | ||
180 | + | ||
181 | + memory_region_init(&s->container, obj, "nrf51-container", UINT64_MAX); | ||
182 | + | ||
183 | + sysbus_init_child_obj(OBJECT(s), "armv6m", OBJECT(&s->cpu), sizeof(s->cpu), | ||
184 | + TYPE_ARMV7M); | ||
185 | + qdev_prop_set_string(DEVICE(&s->cpu), "cpu-type", | ||
186 | + ARM_CPU_TYPE_NAME("cortex-m0")); | ||
187 | + qdev_prop_set_uint32(DEVICE(&s->cpu), "num-irq", 32); | ||
188 | +} | ||
189 | + | ||
190 | +static Property nrf51_soc_properties[] = { | ||
191 | + DEFINE_PROP_LINK("memory", NRF51State, board_memory, TYPE_MEMORY_REGION, | ||
192 | + MemoryRegion *), | ||
193 | + DEFINE_PROP_UINT32("sram-size", NRF51State, sram_size, NRF51822_SRAM_SIZE), | ||
194 | + DEFINE_PROP_UINT32("flash-size", NRF51State, flash_size, | ||
195 | + NRF51822_FLASH_SIZE), | ||
196 | + DEFINE_PROP_END_OF_LIST(), | ||
197 | +}; | ||
198 | + | ||
199 | +static void nrf51_soc_class_init(ObjectClass *klass, void *data) | ||
200 | +{ | ||
201 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
202 | + | ||
203 | + dc->realize = nrf51_soc_realize; | ||
204 | + dc->props = nrf51_soc_properties; | ||
205 | +} | ||
206 | + | ||
207 | +static const TypeInfo nrf51_soc_info = { | ||
208 | + .name = TYPE_NRF51_SOC, | ||
209 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
210 | + .instance_size = sizeof(NRF51State), | ||
211 | + .instance_init = nrf51_soc_init, | ||
212 | + .class_init = nrf51_soc_class_init, | ||
213 | +}; | ||
214 | + | ||
215 | +static void nrf51_soc_types(void) | ||
216 | +{ | ||
217 | + type_register_static(&nrf51_soc_info); | ||
218 | +} | ||
219 | +type_init(nrf51_soc_types) | ||
220 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | ||
221 | index XXXXXXX..XXXXXXX 100644 | ||
222 | --- a/default-configs/arm-softmmu.mak | ||
223 | +++ b/default-configs/arm-softmmu.mak | ||
224 | @@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_SYSCFG=y | ||
225 | CONFIG_STM32F2XX_ADC=y | ||
226 | CONFIG_STM32F2XX_SPI=y | ||
227 | CONFIG_STM32F205_SOC=y | ||
228 | +CONFIG_NRF51_SOC=y | ||
229 | |||
230 | CONFIG_CMSDK_APB_TIMER=y | ||
231 | CONFIG_CMSDK_APB_DUALTIMER=y | ||
232 | -- | 112 | -- |
233 | 2.19.0 | 113 | 2.20.1 |
234 | 114 | ||
235 | 115 | diff view generated by jsdifflib |
1 | Convert the pcnet-pci device away from using the old_mmio | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | MemoryRegionOps accessor functions. | ||
3 | 2 | ||
4 | This commit is a no-behaviour-change API conversion. | 3 | The bcm2835-v3d is used since Linux 4.7, see commit |
5 | (Since PCNET_PNPMMIO_SIZE is 0x20, the old "addr & 0x10" | 4 | 49ac67e0c39c ("ARM: bcm2835: Add VC4 to the device tree"), |
6 | check and the new "addr < 0x10" check are exact opposites; | 5 | and the bcm2835-txp since Linux 4.19, see commit |
7 | the new code is phrased to be parallel with the | 6 | b7dd29b401f5 ("ARM: dts: bcm283x: Add Transposer block"). |
8 | pcnet_io_read/write functions.) | ||
9 | 7 | ||
10 | I have left a TODO comment marker because the similarity | 8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | between the MMIO and IO accessor behaviour is suspicious | 9 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
12 | and they could be combined, but this will be left to a | 10 | Message-id: 20200921034729.432931-3-f4bug@amsat.org |
13 | different patch. | ||
14 | |||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 12 | --- |
18 | hw/net/pcnet-pci.c | 133 ++++++++++++++++++-------------------------- | 13 | include/hw/arm/bcm2835_peripherals.h | 2 ++ |
19 | hw/net/trace-events | 8 +-- | 14 | hw/arm/bcm2835_peripherals.c | 2 ++ |
20 | 2 files changed, 57 insertions(+), 84 deletions(-) | 15 | 2 files changed, 4 insertions(+) |
21 | 16 | ||
22 | diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c | 17 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h |
23 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/net/pcnet-pci.c | 19 | --- a/include/hw/arm/bcm2835_peripherals.h |
25 | +++ b/hw/net/pcnet-pci.c | 20 | +++ b/include/hw/arm/bcm2835_peripherals.h |
26 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pcnet_io_ops = { | 21 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { |
27 | .endianness = DEVICE_LITTLE_ENDIAN, | 22 | |
28 | }; | 23 | BCM2835SystemTimerState systmr; |
29 | 24 | BCM2835MphiState mphi; | |
30 | -static void pcnet_mmio_writeb(void *opaque, hwaddr addr, uint32_t val) | 25 | + UnimplementedDeviceState txp; |
31 | +/* | 26 | UnimplementedDeviceState armtmr; |
32 | + * TODO: should MMIO accesses to the addresses corresponding to the | 27 | UnimplementedDeviceState cprman; |
33 | + * APROM also honour the BCR_DWIO() setting? If so, then these functions | 28 | UnimplementedDeviceState a2w; |
34 | + * and pcnet_ioport_write/pcnet_ioport_read could be merged. | 29 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { |
35 | + * If not, then should pcnet_ioport_{read,write}{w,l} really check | 30 | UnimplementedDeviceState otp; |
36 | + * BCR_DWIO() for MMIO writes ? | 31 | UnimplementedDeviceState dbus; |
37 | + */ | 32 | UnimplementedDeviceState ave0; |
38 | +static void pcnet_mmio_write(void *opaque, hwaddr addr, uint64_t value, | 33 | + UnimplementedDeviceState v3d; |
39 | + unsigned size) | 34 | UnimplementedDeviceState bscsl; |
40 | { | 35 | UnimplementedDeviceState smi; |
41 | PCNetState *d = opaque; | 36 | DWC2State dwc2; |
42 | 37 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | |
43 | - trace_pcnet_mmio_writeb(opaque, addr, val); | 38 | index XXXXXXX..XXXXXXX 100644 |
44 | - if (!(addr & 0x10)) | 39 | --- a/hw/arm/bcm2835_peripherals.c |
45 | - pcnet_aprom_writeb(d, addr & 0x0f, val); | 40 | +++ b/hw/arm/bcm2835_peripherals.c |
46 | -} | 41 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) |
47 | + trace_pcnet_mmio_write(opaque, addr, size, val); | 42 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, |
48 | 43 | INTERRUPT_USB)); | |
49 | -static uint32_t pcnet_mmio_readb(void *opaque, hwaddr addr) | 44 | |
50 | -{ | 45 | + create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); |
51 | - PCNetState *d = opaque; | 46 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); |
52 | - uint32_t val = -1; | 47 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); |
53 | - | 48 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); |
54 | - if (!(addr & 0x10)) | 49 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) |
55 | - val = pcnet_aprom_readb(d, addr & 0x0f); | 50 | create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); |
56 | - trace_pcnet_mmio_readb(opaque, addr, val); | 51 | create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); |
57 | - return val; | 52 | create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); |
58 | -} | 53 | + create_unimp(s, &s->v3d, "bcm2835-v3d", V3D_OFFSET, 0x1000); |
59 | - | 54 | create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100); |
60 | -static void pcnet_mmio_writew(void *opaque, hwaddr addr, uint32_t val) | ||
61 | -{ | ||
62 | - PCNetState *d = opaque; | ||
63 | - | ||
64 | - trace_pcnet_mmio_writew(opaque, addr, val); | ||
65 | - if (addr & 0x10) | ||
66 | - pcnet_ioport_writew(d, addr & 0x0f, val); | ||
67 | - else { | ||
68 | - addr &= 0x0f; | ||
69 | - pcnet_aprom_writeb(d, addr, val & 0xff); | ||
70 | - pcnet_aprom_writeb(d, addr+1, (val & 0xff00) >> 8); | ||
71 | + if (addr < 0x10) { | ||
72 | + if (size == 1) { | ||
73 | + pcnet_aprom_writeb(d, addr, data); | ||
74 | + } else if ((addr & 1) == 0 && size == 2) { | ||
75 | + pcnet_aprom_writeb(d, addr, data & 0xff); | ||
76 | + pcnet_aprom_writeb(d, addr + 1, data >> 8); | ||
77 | + } else if ((addr & 3) == 0 && size == 4) { | ||
78 | + pcnet_aprom_writeb(d, addr, data & 0xff); | ||
79 | + pcnet_aprom_writeb(d, addr + 1, (data >> 8) & 0xff); | ||
80 | + pcnet_aprom_writeb(d, addr + 2, (data >> 16) & 0xff); | ||
81 | + pcnet_aprom_writeb(d, addr + 3, data >> 24); | ||
82 | + } | ||
83 | + } else { | ||
84 | + if (size == 2) { | ||
85 | + pcnet_ioport_writew(d, addr, data); | ||
86 | + } else if (size == 4) { | ||
87 | + pcnet_ioport_writel(d, addr, data); | ||
88 | + } | ||
89 | } | ||
90 | } | 55 | } |
91 | 56 | ||
92 | -static uint32_t pcnet_mmio_readw(void *opaque, hwaddr addr) | ||
93 | -{ | ||
94 | - PCNetState *d = opaque; | ||
95 | - uint32_t val = -1; | ||
96 | - | ||
97 | - if (addr & 0x10) | ||
98 | - val = pcnet_ioport_readw(d, addr & 0x0f); | ||
99 | - else { | ||
100 | - addr &= 0x0f; | ||
101 | - val = pcnet_aprom_readb(d, addr+1); | ||
102 | - val <<= 8; | ||
103 | - val |= pcnet_aprom_readb(d, addr); | ||
104 | - } | ||
105 | - trace_pcnet_mmio_readw(opaque, addr, val); | ||
106 | - return val; | ||
107 | -} | ||
108 | - | ||
109 | -static void pcnet_mmio_writel(void *opaque, hwaddr addr, uint32_t val) | ||
110 | +static uint64_t pcnet_mmio_read(void *opque, hwaddr addr, unsigned size) | ||
111 | { | ||
112 | PCNetState *d = opaque; | ||
113 | |||
114 | - trace_pcnet_mmio_writel(opaque, addr, val); | ||
115 | - if (addr & 0x10) | ||
116 | - pcnet_ioport_writel(d, addr & 0x0f, val); | ||
117 | - else { | ||
118 | - addr &= 0x0f; | ||
119 | - pcnet_aprom_writeb(d, addr, val & 0xff); | ||
120 | - pcnet_aprom_writeb(d, addr+1, (val & 0xff00) >> 8); | ||
121 | - pcnet_aprom_writeb(d, addr+2, (val & 0xff0000) >> 16); | ||
122 | - pcnet_aprom_writeb(d, addr+3, (val & 0xff000000) >> 24); | ||
123 | - } | ||
124 | -} | ||
125 | + trace_pcnet_ioport_read(opaque, addr, size); | ||
126 | |||
127 | -static uint32_t pcnet_mmio_readl(void *opaque, hwaddr addr) | ||
128 | -{ | ||
129 | - PCNetState *d = opaque; | ||
130 | - uint32_t val; | ||
131 | - | ||
132 | - if (addr & 0x10) | ||
133 | - val = pcnet_ioport_readl(d, addr & 0x0f); | ||
134 | - else { | ||
135 | - addr &= 0x0f; | ||
136 | - val = pcnet_aprom_readb(d, addr+3); | ||
137 | - val <<= 8; | ||
138 | - val |= pcnet_aprom_readb(d, addr+2); | ||
139 | - val <<= 8; | ||
140 | - val |= pcnet_aprom_readb(d, addr+1); | ||
141 | - val <<= 8; | ||
142 | - val |= pcnet_aprom_readb(d, addr); | ||
143 | + if (addr < 0x10) { | ||
144 | + if (size == 1) { | ||
145 | + return pcnet_aprom_readb(d, addr); | ||
146 | + } else if ((addr & 1) == 0 && size == 2) { | ||
147 | + return pcnet_aprom_readb(d, addr) | | ||
148 | + (pcnet_aprom_readb(d, addr + 1) << 8); | ||
149 | + } else if ((addr & 3) == 0 && size == 4) { | ||
150 | + return pcnet_aprom_readb(d, addr) | | ||
151 | + (pcnet_aprom_readb(d, addr + 1) << 8) | | ||
152 | + (pcnet_aprom_readb(d, addr + 2) << 16) | | ||
153 | + (pcnet_aprom_readb(d, addr + 3) << 24); | ||
154 | + } | ||
155 | + } else { | ||
156 | + if (size == 2) { | ||
157 | + return pcnet_ioport_readw(d, addr); | ||
158 | + } else if (size == 4) { | ||
159 | + return pcnet_ioport_readl(d, addr); | ||
160 | + } | ||
161 | } | ||
162 | - trace_pcnet_mmio_readl(opaque, addr, val); | ||
163 | - return val; | ||
164 | + return ((uint64_t)1 << (size * 8)) - 1; | ||
165 | } | ||
166 | |||
167 | static const VMStateDescription vmstate_pci_pcnet = { | ||
168 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pci_pcnet = { | ||
169 | /* PCI interface */ | ||
170 | |||
171 | static const MemoryRegionOps pcnet_mmio_ops = { | ||
172 | - .old_mmio = { | ||
173 | - .read = { pcnet_mmio_readb, pcnet_mmio_readw, pcnet_mmio_readl }, | ||
174 | - .write = { pcnet_mmio_writeb, pcnet_mmio_writew, pcnet_mmio_writel }, | ||
175 | - }, | ||
176 | + .read = pcnet_mmio_read, | ||
177 | + .write = pcnet_mmio_write, | ||
178 | + .valid.min_access_size = 1, | ||
179 | + .valid.max_access_size = 4, | ||
180 | + .impl.min_access_size = 1, | ||
181 | + .impl.max_access_size = 4, | ||
182 | .endianness = DEVICE_LITTLE_ENDIAN, | ||
183 | }; | ||
184 | |||
185 | diff --git a/hw/net/trace-events b/hw/net/trace-events | ||
186 | index XXXXXXX..XXXXXXX 100644 | ||
187 | --- a/hw/net/trace-events | ||
188 | +++ b/hw/net/trace-events | ||
189 | @@ -XXX,XX +XXX,XX @@ pcnet_aprom_writeb(void *opaque, uint32_t addr, uint32_t val) "opaque=%p addr=0x | ||
190 | pcnet_aprom_readb(void *opaque, uint32_t addr, uint32_t val) "opaque=%p addr=0x%08x val=0x%02x" | ||
191 | pcnet_ioport_read(void *opaque, uint64_t addr, unsigned size) "opaque=%p addr=0x%"PRIx64" size=%d" | ||
192 | pcnet_ioport_write(void *opaque, uint64_t addr, uint64_t data, unsigned size) "opaque=%p addr=0x%"PRIx64" data=0x%"PRIx64" size=%d" | ||
193 | -pcnet_mmio_writeb(void *opaque, uint64_t addr, uint32_t val) "opaque=%p addr=0x%"PRIx64" val=0x%x" | ||
194 | -pcnet_mmio_writew(void *opaque, uint64_t addr, uint32_t val) "opaque=%p addr=0x%"PRIx64" val=0x%x" | ||
195 | -pcnet_mmio_writel(void *opaque, uint64_t addr, uint32_t val) "opaque=%p addr=0x%"PRIx64" val=0x%x" | ||
196 | -pcnet_mmio_readb(void *opaque, uint64_t addr, uint32_t val) "opaque=%p addr=0x%"PRIx64" val=0x%x" | ||
197 | -pcnet_mmio_readw(void *opaque, uint64_t addr, uint32_t val) "opaque=%p addr=0x%"PRIx64" val=0x%x" | ||
198 | -pcnet_mmio_readl(void *opaque, uint64_t addr, uint32_t val) "opaque=%p addr=0x%"PRIx64" val=0x%x" | ||
199 | +pcnet_mmio_write(void *opaque, uint64_t addr, uint32_t val, unsigned size) "opaque=%p addr=0x%"PRIx64" val=0x%x size=%d" | ||
200 | +pcnet_mmio_read(void *opaque, uint64_t addr, unsigned size) "opaque=%p addr=0x%"PRIx64" size=%d" | ||
201 | |||
202 | # hw/net/net_rx_pkt.c | ||
203 | net_rx_pkt_parsed(bool ip4, bool ip6, bool udp, bool tcp, size_t l3o, size_t l4o, size_t l5o) "RX packet parsed: ip4: %d, ip6: %d, udp: %d, tcp: %d, l3 offset: %zu, l4 offset: %zu, l5 offset: %zu" | ||
204 | -- | 57 | -- |
205 | 2.19.0 | 58 | 2.20.1 |
206 | 59 | ||
207 | 60 | diff view generated by jsdifflib |
1 | The only difference between our implementation of the pcnet ioport | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | accessors and the mmio accessors is that the former check BCR_DWIO to | ||
3 | see what access widths are permitted for addresses in the aprom range | ||
4 | (0x0..0xf). In fact our failure to do this in the mmio accessors | ||
5 | is a bug (one which was fixed for the ioport accessors in | ||
6 | commit 7ba79741970 in 2011). | ||
7 | 2 | ||
8 | The data sheet for the Am79C970A does not describe the DWIO | 3 | Commit 1c3db49d39 added the raspi3, which uses the same peripherals |
9 | bit as only applying for I/O space mapped I/O resources and | 4 | than the raspi2 (but with different ARM cores). The raspi3 was |
10 | not memory mapped I/O resources, and our MMIO accessors already | 5 | introduced without the ignore_memory_transaction_failures flag. |
11 | honour DWIO for accesses in the 0x10..0x1f range (since the | 6 | Almost 2 years later, the machine is usable running U-Boot and |
12 | pcnet_ioport_{read,write}{w,l} functions check it). | 7 | Linux. |
13 | 8 | In commit 00cbd5bd74 we mapped a lot of unimplemented devices, | |
14 | The data sheet for the later but compatible Am79C976 is clearer: | 9 | commit d442d95f added thermal block and commit 0e5bbd7406 the |
15 | it states specifically "DWIO mode applies to both I/O- and | 10 | system timer. |
16 | memory-mapped acceses." This seems to be reasonable evidence | 11 | As we are happy with the raspi3, let's remove this flag on the |
17 | in favour of interpretating the Am79C970A spec as being the same. | 12 | raspi2. |
18 | |||
19 | (NB: Linux's pcnet driver only supports I/O accesses, so the | ||
20 | MMIO access part of this device is probably untested anyway.) | ||
21 | 13 | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
16 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20200921034729.432931-4-f4bug@amsat.org | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 19 | --- |
25 | hw/net/pcnet-pci.c | 67 ++------------------------------------------- | 20 | hw/arm/raspi.c | 3 --- |
26 | hw/net/trace-events | 2 -- | 21 | 1 file changed, 3 deletions(-) |
27 | 2 files changed, 2 insertions(+), 67 deletions(-) | ||
28 | 22 | ||
29 | diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c | 23 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
30 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/net/pcnet-pci.c | 25 | --- a/hw/arm/raspi.c |
32 | +++ b/hw/net/pcnet-pci.c | 26 | +++ b/hw/arm/raspi.c |
33 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pcnet_io_ops = { | 27 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) |
34 | .endianness = DEVICE_LITTLE_ENDIAN, | 28 | mc->default_cpus = mc->min_cpus = mc->max_cpus = cores_count(board_rev); |
29 | mc->default_ram_size = board_ram_size(board_rev); | ||
30 | mc->default_ram_id = "ram"; | ||
31 | - if (board_version(board_rev) == 2) { | ||
32 | - mc->ignore_memory_transaction_failures = true; | ||
33 | - } | ||
35 | }; | 34 | }; |
36 | 35 | ||
37 | -/* | 36 | static const TypeInfo raspi_machine_types[] = { |
38 | - * TODO: should MMIO accesses to the addresses corresponding to the | ||
39 | - * APROM also honour the BCR_DWIO() setting? If so, then these functions | ||
40 | - * and pcnet_ioport_write/pcnet_ioport_read could be merged. | ||
41 | - * If not, then should pcnet_ioport_{read,write}{w,l} really check | ||
42 | - * BCR_DWIO() for MMIO writes ? | ||
43 | - */ | ||
44 | -static void pcnet_mmio_write(void *opaque, hwaddr addr, uint64_t value, | ||
45 | - unsigned size) | ||
46 | -{ | ||
47 | - PCNetState *d = opaque; | ||
48 | - | ||
49 | - trace_pcnet_mmio_write(opaque, addr, size, val); | ||
50 | - | ||
51 | - if (addr < 0x10) { | ||
52 | - if (size == 1) { | ||
53 | - pcnet_aprom_writeb(d, addr, data); | ||
54 | - } else if ((addr & 1) == 0 && size == 2) { | ||
55 | - pcnet_aprom_writeb(d, addr, data & 0xff); | ||
56 | - pcnet_aprom_writeb(d, addr + 1, data >> 8); | ||
57 | - } else if ((addr & 3) == 0 && size == 4) { | ||
58 | - pcnet_aprom_writeb(d, addr, data & 0xff); | ||
59 | - pcnet_aprom_writeb(d, addr + 1, (data >> 8) & 0xff); | ||
60 | - pcnet_aprom_writeb(d, addr + 2, (data >> 16) & 0xff); | ||
61 | - pcnet_aprom_writeb(d, addr + 3, data >> 24); | ||
62 | - } | ||
63 | - } else { | ||
64 | - if (size == 2) { | ||
65 | - pcnet_ioport_writew(d, addr, data); | ||
66 | - } else if (size == 4) { | ||
67 | - pcnet_ioport_writel(d, addr, data); | ||
68 | - } | ||
69 | - } | ||
70 | -} | ||
71 | - | ||
72 | -static uint64_t pcnet_mmio_read(void *opque, hwaddr addr, unsigned size) | ||
73 | -{ | ||
74 | - PCNetState *d = opaque; | ||
75 | - | ||
76 | - trace_pcnet_ioport_read(opaque, addr, size); | ||
77 | - | ||
78 | - if (addr < 0x10) { | ||
79 | - if (size == 1) { | ||
80 | - return pcnet_aprom_readb(d, addr); | ||
81 | - } else if ((addr & 1) == 0 && size == 2) { | ||
82 | - return pcnet_aprom_readb(d, addr) | | ||
83 | - (pcnet_aprom_readb(d, addr + 1) << 8); | ||
84 | - } else if ((addr & 3) == 0 && size == 4) { | ||
85 | - return pcnet_aprom_readb(d, addr) | | ||
86 | - (pcnet_aprom_readb(d, addr + 1) << 8) | | ||
87 | - (pcnet_aprom_readb(d, addr + 2) << 16) | | ||
88 | - (pcnet_aprom_readb(d, addr + 3) << 24); | ||
89 | - } | ||
90 | - } else { | ||
91 | - if (size == 2) { | ||
92 | - return pcnet_ioport_readw(d, addr); | ||
93 | - } else if (size == 4) { | ||
94 | - return pcnet_ioport_readl(d, addr); | ||
95 | - } | ||
96 | - } | ||
97 | - return ((uint64_t)1 << (size * 8)) - 1; | ||
98 | -} | ||
99 | - | ||
100 | static const VMStateDescription vmstate_pci_pcnet = { | ||
101 | .name = "pcnet", | ||
102 | .version_id = 3, | ||
103 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pci_pcnet = { | ||
104 | /* PCI interface */ | ||
105 | |||
106 | static const MemoryRegionOps pcnet_mmio_ops = { | ||
107 | - .read = pcnet_mmio_read, | ||
108 | - .write = pcnet_mmio_write, | ||
109 | + .read = pcnet_ioport_read, | ||
110 | + .write = pcnet_ioport_write, | ||
111 | .valid.min_access_size = 1, | ||
112 | .valid.max_access_size = 4, | ||
113 | .impl.min_access_size = 1, | ||
114 | diff --git a/hw/net/trace-events b/hw/net/trace-events | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/hw/net/trace-events | ||
117 | +++ b/hw/net/trace-events | ||
118 | @@ -XXX,XX +XXX,XX @@ pcnet_aprom_writeb(void *opaque, uint32_t addr, uint32_t val) "opaque=%p addr=0x | ||
119 | pcnet_aprom_readb(void *opaque, uint32_t addr, uint32_t val) "opaque=%p addr=0x%08x val=0x%02x" | ||
120 | pcnet_ioport_read(void *opaque, uint64_t addr, unsigned size) "opaque=%p addr=0x%"PRIx64" size=%d" | ||
121 | pcnet_ioport_write(void *opaque, uint64_t addr, uint64_t data, unsigned size) "opaque=%p addr=0x%"PRIx64" data=0x%"PRIx64" size=%d" | ||
122 | -pcnet_mmio_write(void *opaque, uint64_t addr, uint32_t val, unsigned size) "opaque=%p addr=0x%"PRIx64" val=0x%x size=%d" | ||
123 | -pcnet_mmio_read(void *opaque, uint64_t addr, unsigned size) "opaque=%p addr=0x%"PRIx64" size=%d" | ||
124 | |||
125 | # hw/net/net_rx_pkt.c | ||
126 | net_rx_pkt_parsed(bool ip4, bool ip6, bool udp, bool tcp, size_t l3o, size_t l4o, size_t l5o) "RX packet parsed: ip4: %d, ip6: %d, udp: %d, tcp: %d, l3 offset: %zu, l4 offset: %zu, l5 offset: %zu" | ||
127 | -- | 37 | -- |
128 | 2.19.0 | 38 | 2.20.1 |
129 | 39 | ||
130 | 40 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The event queue management is broken today. Event records | 3 | Display the board revision in the machine description. |
4 | are not properly written as EVT_SET_* macro was not updating | ||
5 | the actual event record. Also the event queue interrupt | ||
6 | is not correctly triggered. | ||
7 | 4 | ||
8 | Fixes: bb981004eaf4 ("hw/arm/smmuv3: Event queue recording helper") | 5 | Before: |
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 6 | |
10 | Message-id: 20180921070138.10114-3-eric.auger@redhat.com | 7 | $ qemu-system-aarch64 -M help | fgrep raspi |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | raspi2 Raspberry Pi 2B |
9 | raspi3 Raspberry Pi 3B | ||
10 | |||
11 | After: | ||
12 | |||
13 | raspi2 Raspberry Pi 2B (revision 1.1) | ||
14 | raspi3 Raspberry Pi 3B (revision 1.2) | ||
15 | |||
16 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
17 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Message-id: 20200924111808.77168-2-f4bug@amsat.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 20 | --- |
14 | hw/arm/smmuv3-internal.h | 26 +++++++++++++------------- | 21 | hw/arm/raspi.c | 4 +++- |
15 | hw/arm/smmuv3.c | 2 +- | 22 | 1 file changed, 3 insertions(+), 1 deletion(-) |
16 | 2 files changed, 14 insertions(+), 14 deletions(-) | ||
17 | 23 | ||
18 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | 24 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
19 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/smmuv3-internal.h | 26 | --- a/hw/arm/raspi.c |
21 | +++ b/hw/arm/smmuv3-internal.h | 27 | +++ b/hw/arm/raspi.c |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUEventInfo { | 28 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) |
23 | 29 | uint32_t board_rev = (uint32_t)(uintptr_t)data; | |
24 | #define EVT_Q_OVERFLOW (1 << 31) | 30 | |
25 | 31 | rmc->board_rev = board_rev; | |
26 | -#define EVT_SET_TYPE(x, v) deposit32((x)->word[0], 0 , 8 , v) | 32 | - mc->desc = g_strdup_printf("Raspberry Pi %s", board_type(board_rev)); |
27 | -#define EVT_SET_SSV(x, v) deposit32((x)->word[0], 11, 1 , v) | 33 | + mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)", |
28 | -#define EVT_SET_SSID(x, v) deposit32((x)->word[0], 12, 20, v) | 34 | + board_type(board_rev), |
29 | -#define EVT_SET_SID(x, v) ((x)->word[1] = v) | 35 | + FIELD_EX32(board_rev, REV_CODE, REVISION)); |
30 | -#define EVT_SET_STAG(x, v) deposit32((x)->word[2], 0 , 16, v) | 36 | mc->init = raspi_machine_init; |
31 | -#define EVT_SET_STALL(x, v) deposit32((x)->word[2], 31, 1 , v) | 37 | mc->block_default_type = IF_SD; |
32 | -#define EVT_SET_PNU(x, v) deposit32((x)->word[3], 1 , 1 , v) | 38 | mc->no_parallel = 1; |
33 | -#define EVT_SET_IND(x, v) deposit32((x)->word[3], 2 , 1 , v) | ||
34 | -#define EVT_SET_RNW(x, v) deposit32((x)->word[3], 3 , 1 , v) | ||
35 | -#define EVT_SET_S2(x, v) deposit32((x)->word[3], 7 , 1 , v) | ||
36 | -#define EVT_SET_CLASS(x, v) deposit32((x)->word[3], 8 , 2 , v) | ||
37 | +#define EVT_SET_TYPE(x, v) ((x)->word[0] = deposit32((x)->word[0], 0 , 8 , v)) | ||
38 | +#define EVT_SET_SSV(x, v) ((x)->word[0] = deposit32((x)->word[0], 11, 1 , v)) | ||
39 | +#define EVT_SET_SSID(x, v) ((x)->word[0] = deposit32((x)->word[0], 12, 20, v)) | ||
40 | +#define EVT_SET_SID(x, v) ((x)->word[1] = v) | ||
41 | +#define EVT_SET_STAG(x, v) ((x)->word[2] = deposit32((x)->word[2], 0 , 16, v)) | ||
42 | +#define EVT_SET_STALL(x, v) ((x)->word[2] = deposit32((x)->word[2], 31, 1 , v)) | ||
43 | +#define EVT_SET_PNU(x, v) ((x)->word[3] = deposit32((x)->word[3], 1 , 1 , v)) | ||
44 | +#define EVT_SET_IND(x, v) ((x)->word[3] = deposit32((x)->word[3], 2 , 1 , v)) | ||
45 | +#define EVT_SET_RNW(x, v) ((x)->word[3] = deposit32((x)->word[3], 3 , 1 , v)) | ||
46 | +#define EVT_SET_S2(x, v) ((x)->word[3] = deposit32((x)->word[3], 7 , 1 , v)) | ||
47 | +#define EVT_SET_CLASS(x, v) ((x)->word[3] = deposit32((x)->word[3], 8 , 2 , v)) | ||
48 | #define EVT_SET_ADDR(x, addr) \ | ||
49 | do { \ | ||
50 | (x)->word[5] = (uint32_t)(addr >> 32); \ | ||
51 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUEventInfo { | ||
52 | } while (0) | ||
53 | #define EVT_SET_ADDR2(x, addr) \ | ||
54 | do { \ | ||
55 | - deposit32((x)->word[7], 3, 29, addr >> 16); \ | ||
56 | - deposit32((x)->word[7], 0, 16, addr & 0xffff);\ | ||
57 | + (x)->word[7] = deposit32((x)->word[7], 3, 29, addr >> 16); \ | ||
58 | + (x)->word[7] = deposit32((x)->word[7], 0, 16, addr & 0xffff);\ | ||
59 | } while (0) | ||
60 | |||
61 | void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event); | ||
62 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/arm/smmuv3.c | ||
65 | +++ b/hw/arm/smmuv3.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, Evt *evt) | ||
67 | return r; | ||
68 | } | ||
69 | |||
70 | - if (smmuv3_q_empty(q)) { | ||
71 | + if (!smmuv3_q_empty(q)) { | ||
72 | smmuv3_trigger_irq(s, SMMU_IRQ_EVTQ, 0); | ||
73 | } | ||
74 | return MEMTX_OK; | ||
75 | -- | 39 | -- |
76 | 2.19.0 | 40 | 2.20.1 |
77 | 41 | ||
78 | 42 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <shannon.zhaosl@gmail.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Like commit 16b4226(hw/acpi-build: Add a check for memory-less NUMA node | 3 | The 'first_cpu' is more a QEMU accelerator-related concept |
4 | ), it also needs to check memory length for NUMA nodes on ARM. | 4 | than a variable the machine requires to use. |
5 | Since the machine is aware of its CPUs, directly use the | ||
6 | first one to load the firmware. | ||
5 | 7 | ||
6 | Signed-off-by: Shannon Zhao <shannon.zhaosl@gmail.com> | 8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
7 | Reviewed-by: Andrew Jones <drjones@redhat.com> | 9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Message-id: 20180911112643.19296-1-shenglong.zsl@alibaba-inc.com | 10 | Message-id: 20200924111808.77168-3-f4bug@amsat.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | hw/arm/virt-acpi-build.c | 10 ++++++---- | 13 | hw/arm/raspi.c | 3 ++- |
12 | 1 file changed, 6 insertions(+), 4 deletions(-) | 14 | 1 file changed, 2 insertions(+), 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/virt-acpi-build.c | 18 | --- a/hw/arm/raspi.c |
17 | +++ b/hw/arm/virt-acpi-build.c | 19 | +++ b/hw/arm/raspi.c |
18 | @@ -XXX,XX +XXX,XX @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 20 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) |
19 | 21 | ||
20 | mem_base = vms->memmap[VIRT_MEM].base; | 22 | static void setup_boot(MachineState *machine, int version, size_t ram_size) |
21 | for (i = 0; i < nb_numa_nodes; ++i) { | 23 | { |
22 | - numamem = acpi_data_push(table_data, sizeof(*numamem)); | 24 | + RaspiMachineState *s = RASPI_MACHINE(machine); |
23 | - build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i, | 25 | static struct arm_boot_info binfo; |
24 | - MEM_AFFINITY_ENABLED); | 26 | int r; |
25 | - mem_base += numa_info[i].node_mem; | 27 | |
26 | + if (numa_info[i].node_mem > 0) { | 28 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
27 | + numamem = acpi_data_push(table_data, sizeof(*numamem)); | 29 | binfo.firmware_loaded = true; |
28 | + build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i, | ||
29 | + MEM_AFFINITY_ENABLED); | ||
30 | + mem_base += numa_info[i].node_mem; | ||
31 | + } | ||
32 | } | 30 | } |
33 | 31 | ||
34 | build_header(linker, table_data, (void *)(table_data->data + srat_start), | 32 | - arm_load_kernel(ARM_CPU(first_cpu), machine, &binfo); |
33 | + arm_load_kernel(&s->soc.cpu[0].core, machine, &binfo); | ||
34 | } | ||
35 | |||
36 | static void raspi_machine_init(MachineState *machine) | ||
35 | -- | 37 | -- |
36 | 2.19.0 | 38 | 2.20.1 |
37 | 39 | ||
38 | 40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | This contains the NRF51, and the machine that uses it, the BBC | ||
4 | micro:bit. | ||
5 | |||
6 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
9 | Message-id: 20180831220920.27113-2-joel@jms.id.au | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | MAINTAINERS | 8 ++++++++ | ||
13 | 1 file changed, 8 insertions(+) | ||
14 | |||
15 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/MAINTAINERS | ||
18 | +++ b/MAINTAINERS | ||
19 | @@ -XXX,XX +XXX,XX @@ F: include/hw/*/*aspeed* | ||
20 | F: hw/net/ftgmac100.c | ||
21 | F: include/hw/net/ftgmac100.h | ||
22 | |||
23 | +NRF51 | ||
24 | +M: Joel Stanley <joel@jms.id.au> | ||
25 | +L: qemu-arm@nongnu.org | ||
26 | +S: Maintained | ||
27 | +F: hw/arm/nrf51_soc.c | ||
28 | +F: hw/arm/microbit.c | ||
29 | +F: include/hw/arm/nrf51_soc.h | ||
30 | + | ||
31 | CRIS Machines | ||
32 | ------------- | ||
33 | Axis Dev88 | ||
34 | -- | ||
35 | 2.19.0 | ||
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The AST2500 datasheet says: | 3 | The arm_boot_info structure belong to the machine, |
4 | move it to RaspiMachineState. | ||
4 | 5 | ||
5 | I2CD10 Interrupt Status Register | 6 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
6 | bit 2 Receive Done Interrupt status | 7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | S/W needs to clear this status bit to allow next data receiving | 8 | Message-id: 20200924111808.77168-4-f4bug@amsat.org |
8 | |||
9 | The Rx interrupt done interrupt status bit needs to be cleared | ||
10 | explicitly before the next byte can be received, and must therefore | ||
11 | not be auto-cleared. Also, receiving the next byte must be delayed | ||
12 | until the bit has been cleared. | ||
13 | |||
14 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
16 | Message-id: 20180914063506.20815-4-clg@kaod.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 10 | --- |
19 | hw/i2c/aspeed_i2c.c | 10 +++++++++- | 11 | hw/arm/raspi.c | 30 +++++++++++++++--------------- |
20 | 1 file changed, 9 insertions(+), 1 deletion(-) | 12 | 1 file changed, 15 insertions(+), 15 deletions(-) |
21 | 13 | ||
22 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | 14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/i2c/aspeed_i2c.c | 16 | --- a/hw/arm/raspi.c |
25 | +++ b/hw/i2c/aspeed_i2c.c | 17 | +++ b/hw/arm/raspi.c |
26 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | 18 | @@ -XXX,XX +XXX,XX @@ struct RaspiMachineState { |
27 | aspeed_i2c_set_state(bus, I2CD_MACTIVE); | 19 | MachineState parent_obj; |
20 | /*< public >*/ | ||
21 | BCM283XState soc; | ||
22 | + struct arm_boot_info binfo; | ||
23 | }; | ||
24 | typedef struct RaspiMachineState RaspiMachineState; | ||
25 | |||
26 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | ||
27 | static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
28 | { | ||
29 | RaspiMachineState *s = RASPI_MACHINE(machine); | ||
30 | - static struct arm_boot_info binfo; | ||
31 | int r; | ||
32 | |||
33 | - binfo.board_id = MACH_TYPE_BCM2708; | ||
34 | - binfo.ram_size = ram_size; | ||
35 | - binfo.nb_cpus = machine->smp.cpus; | ||
36 | + s->binfo.board_id = MACH_TYPE_BCM2708; | ||
37 | + s->binfo.ram_size = ram_size; | ||
38 | + s->binfo.nb_cpus = machine->smp.cpus; | ||
39 | |||
40 | if (version <= 2) { | ||
41 | /* The rpi1 and 2 require some custom setup code to run in Secure | ||
42 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
43 | * firmware for some cache maintenance operations. | ||
44 | * The rpi3 doesn't need this. | ||
45 | */ | ||
46 | - binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
47 | - binfo.write_board_setup = write_board_setup; | ||
48 | - binfo.secure_board_setup = true; | ||
49 | - binfo.secure_boot = true; | ||
50 | + s->binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
51 | + s->binfo.write_board_setup = write_board_setup; | ||
52 | + s->binfo.secure_board_setup = true; | ||
53 | + s->binfo.secure_boot = true; | ||
28 | } | 54 | } |
29 | 55 | ||
30 | - if (bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST)) { | 56 | /* Pi2 and Pi3 requires SMP setup */ |
31 | + if ((bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST)) && | 57 | if (version >= 2) { |
32 | + !(bus->intr_status & I2CD_INTR_RX_DONE)) { | 58 | - binfo.smp_loader_start = SMPBOOT_ADDR; |
33 | aspeed_i2c_handle_rx_cmd(bus); | 59 | + s->binfo.smp_loader_start = SMPBOOT_ADDR; |
60 | if (version == 2) { | ||
61 | - binfo.write_secondary_boot = write_smpboot; | ||
62 | + s->binfo.write_secondary_boot = write_smpboot; | ||
63 | } else { | ||
64 | - binfo.write_secondary_boot = write_smpboot64; | ||
65 | + s->binfo.write_secondary_boot = write_smpboot64; | ||
66 | } | ||
67 | - binfo.secondary_cpu_reset_hook = reset_secondary; | ||
68 | + s->binfo.secondary_cpu_reset_hook = reset_secondary; | ||
34 | } | 69 | } |
35 | 70 | ||
36 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | 71 | /* If the user specified a "firmware" image (e.g. UEFI), we bypass |
37 | uint64_t value, unsigned size) | 72 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
38 | { | 73 | exit(1); |
39 | AspeedI2CBus *bus = opaque; | ||
40 | + bool handle_rx; | ||
41 | |||
42 | switch (offset) { | ||
43 | case I2CD_FUN_CTRL_REG: | ||
44 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
45 | bus->intr_ctrl = value & 0x7FFF; | ||
46 | break; | ||
47 | case I2CD_INTR_STS_REG: | ||
48 | + handle_rx = (bus->intr_status & I2CD_INTR_RX_DONE) && | ||
49 | + (value & I2CD_INTR_RX_DONE); | ||
50 | bus->intr_status &= ~(value & 0x7FFF); | ||
51 | if (!bus->intr_status) { | ||
52 | bus->controller->intr_status &= ~(1 << bus->id); | ||
53 | qemu_irq_lower(bus->controller->irq); | ||
54 | } | 74 | } |
55 | + if (handle_rx && (bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST))) { | 75 | |
56 | + aspeed_i2c_handle_rx_cmd(bus); | 76 | - binfo.entry = firmware_addr; |
57 | + aspeed_i2c_bus_raise_interrupt(bus); | 77 | - binfo.firmware_loaded = true; |
58 | + } | 78 | + s->binfo.entry = firmware_addr; |
59 | break; | 79 | + s->binfo.firmware_loaded = true; |
60 | case I2CD_DEV_ADDR_REG: | 80 | } |
61 | qemu_log_mask(LOG_UNIMP, "%s: slave mode not implemented\n", | 81 | |
82 | - arm_load_kernel(&s->soc.cpu[0].core, machine, &binfo); | ||
83 | + arm_load_kernel(&s->soc.cpu[0].core, machine, &s->binfo); | ||
84 | } | ||
85 | |||
86 | static void raspi_machine_init(MachineState *machine) | ||
62 | -- | 87 | -- |
63 | 2.19.0 | 88 | 2.20.1 |
64 | 89 | ||
65 | 90 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | This adds the base for a machine model of the BBC micro:bit: | 3 | Using class_data pointer to create a MachineClass is not |
4 | the recommended way anymore. The correct way is to open-code | ||
5 | the MachineClass::fields in the class_init() method. | ||
4 | 6 | ||
5 | https://en.wikipedia.org/wiki/Micro_Bit | 7 | We can not use TYPE_RASPI_MACHINE::class_base_init() because |
8 | it is called *before* each machine class_init(), therefore the | ||
9 | board_rev field is not populated. We have to manually call | ||
10 | raspi_machine_class_common_init() for each machine. | ||
6 | 11 | ||
7 | This is a system with a nRF51 SoC containing the main processor, with | 12 | This partly reverts commit a03bde3674e. |
8 | various peripherals on board. | ||
9 | 13 | ||
10 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 14 | Suggested-by: Igor Mammedov <imammedo@redhat.com> |
11 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20180831220920.27113-4-joel@jms.id.au | 16 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
18 | Message-id: 20200924111808.77168-5-f4bug@amsat.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 20 | --- |
16 | hw/arm/Makefile.objs | 2 +- | 21 | hw/arm/raspi.c | 34 ++++++++++++++++++++++++---------- |
17 | hw/arm/microbit.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ | 22 | 1 file changed, 24 insertions(+), 10 deletions(-) |
18 | 2 files changed, 68 insertions(+), 1 deletion(-) | ||
19 | create mode 100644 hw/arm/microbit.c | ||
20 | 23 | ||
21 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 24 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
22 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/arm/Makefile.objs | 26 | --- a/hw/arm/raspi.c |
24 | +++ b/hw/arm/Makefile.objs | 27 | +++ b/hw/arm/raspi.c |
25 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_IOTKIT) += iotkit.o | 28 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) |
26 | obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o | 29 | setup_boot(machine, version, machine->ram_size - vcram_size); |
27 | obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o | 30 | } |
28 | obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.o | 31 | |
29 | -obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o | 32 | -static void raspi_machine_class_init(ObjectClass *oc, void *data) |
30 | +obj-$(CONFIG_NRF51_SOC) += nrf51_soc.o microbit.o | 33 | +static void raspi_machine_class_common_init(MachineClass *mc, |
31 | diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c | 34 | + uint32_t board_rev) |
32 | new file mode 100644 | 35 | { |
33 | index XXXXXXX..XXXXXXX | 36 | - MachineClass *mc = MACHINE_CLASS(oc); |
34 | --- /dev/null | 37 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); |
35 | +++ b/hw/arm/microbit.c | 38 | - uint32_t board_rev = (uint32_t)(uintptr_t)data; |
36 | @@ -XXX,XX +XXX,XX @@ | 39 | - |
37 | +/* | 40 | - rmc->board_rev = board_rev; |
38 | + * BBC micro:bit machine | 41 | mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)", |
39 | + * http://tech.microbit.org/hardware/ | 42 | board_type(board_rev), |
40 | + * | 43 | FIELD_EX32(board_rev, REV_CODE, REVISION)); |
41 | + * Copyright 2018 Joel Stanley <joel@jms.id.au> | 44 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_init(ObjectClass *oc, void *data) |
42 | + * | 45 | mc->default_ram_id = "ram"; |
43 | + * This code is licensed under the GPL version 2 or later. See | 46 | }; |
44 | + * the COPYING file in the top-level directory. | 47 | |
45 | + */ | 48 | +static void raspi2b_machine_class_init(ObjectClass *oc, void *data) |
46 | + | ||
47 | +#include "qemu/osdep.h" | ||
48 | +#include "qapi/error.h" | ||
49 | +#include "hw/boards.h" | ||
50 | +#include "hw/arm/arm.h" | ||
51 | +#include "exec/address-spaces.h" | ||
52 | + | ||
53 | +#include "hw/arm/nrf51_soc.h" | ||
54 | + | ||
55 | +typedef struct { | ||
56 | + MachineState parent; | ||
57 | + | ||
58 | + NRF51State nrf51; | ||
59 | +} MicrobitMachineState; | ||
60 | + | ||
61 | +#define TYPE_MICROBIT_MACHINE MACHINE_TYPE_NAME("microbit") | ||
62 | + | ||
63 | +#define MICROBIT_MACHINE(obj) \ | ||
64 | + OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE) | ||
65 | + | ||
66 | +static void microbit_init(MachineState *machine) | ||
67 | +{ | ||
68 | + MicrobitMachineState *s = MICROBIT_MACHINE(machine); | ||
69 | + MemoryRegion *system_memory = get_system_memory(); | ||
70 | + Object *soc = OBJECT(&s->nrf51); | ||
71 | + | ||
72 | + sysbus_init_child_obj(OBJECT(machine), "nrf51", soc, sizeof(s->nrf51), | ||
73 | + TYPE_NRF51_SOC); | ||
74 | + object_property_set_link(soc, OBJECT(system_memory), "memory", | ||
75 | + &error_fatal); | ||
76 | + object_property_set_bool(soc, true, "realized", &error_fatal); | ||
77 | + | ||
78 | + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, | ||
79 | + NRF51_SOC(soc)->flash_size); | ||
80 | +} | ||
81 | + | ||
82 | +static void microbit_machine_class_init(ObjectClass *oc, void *data) | ||
83 | +{ | 49 | +{ |
84 | + MachineClass *mc = MACHINE_CLASS(oc); | 50 | + MachineClass *mc = MACHINE_CLASS(oc); |
51 | + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
85 | + | 52 | + |
86 | + mc->desc = "BBC micro:bit"; | 53 | + rmc->board_rev = 0xa21041; |
87 | + mc->init = microbit_init; | 54 | + raspi_machine_class_common_init(mc, rmc->board_rev); |
88 | + mc->max_cpus = 1; | ||
89 | +} | ||
90 | + | ||
91 | +static const TypeInfo microbit_info = { | ||
92 | + .name = TYPE_MICROBIT_MACHINE, | ||
93 | + .parent = TYPE_MACHINE, | ||
94 | + .instance_size = sizeof(MicrobitMachineState), | ||
95 | + .class_init = microbit_machine_class_init, | ||
96 | +}; | 55 | +}; |
97 | + | 56 | + |
98 | +static void microbit_machine_init(void) | 57 | +#ifdef TARGET_AARCH64 |
58 | +static void raspi3b_machine_class_init(ObjectClass *oc, void *data) | ||
99 | +{ | 59 | +{ |
100 | + type_register_static(µbit_info); | 60 | + MachineClass *mc = MACHINE_CLASS(oc); |
101 | +} | 61 | + RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); |
102 | + | 62 | + |
103 | +type_init(microbit_machine_init); | 63 | + rmc->board_rev = 0xa02082; |
64 | + raspi_machine_class_common_init(mc, rmc->board_rev); | ||
65 | +}; | ||
66 | +#endif /* TARGET_AARCH64 */ | ||
67 | + | ||
68 | static const TypeInfo raspi_machine_types[] = { | ||
69 | { | ||
70 | .name = MACHINE_TYPE_NAME("raspi2"), | ||
71 | .parent = TYPE_RASPI_MACHINE, | ||
72 | - .class_init = raspi_machine_class_init, | ||
73 | - .class_data = (void *)0xa21041, | ||
74 | + .class_init = raspi2b_machine_class_init, | ||
75 | #ifdef TARGET_AARCH64 | ||
76 | }, { | ||
77 | .name = MACHINE_TYPE_NAME("raspi3"), | ||
78 | .parent = TYPE_RASPI_MACHINE, | ||
79 | - .class_init = raspi_machine_class_init, | ||
80 | - .class_data = (void *)0xa02082, | ||
81 | + .class_init = raspi3b_machine_class_init, | ||
82 | #endif | ||
83 | }, { | ||
84 | .name = TYPE_RASPI_MACHINE, | ||
104 | -- | 85 | -- |
105 | 2.19.0 | 86 | 2.20.1 |
106 | 87 | ||
107 | 88 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | At the point smmu_find_add_as() gets called, the bus number might | 3 | Now that we can instantiate different machines based on their |
4 | not be computed. Let's change the name of IOMMU memory region and | 4 | board_rev register value, we can have various raspi2 and raspi3. |
5 | just use the devfn and an incrementing index. | ||
6 | 5 | ||
7 | The name only is used for debug. | 6 | In commit fc78a990ec103 we corrected the machine description. |
7 | Correct the machine names too. For backward compatibility, add | ||
8 | an alias to the previous generic name. | ||
8 | 9 | ||
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 10 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
10 | Message-id: 20180921070138.10114-2-eric.auger@redhat.com | 11 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Message-id: 20200924111808.77168-6-f4bug@amsat.org |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 14 | --- |
14 | hw/arm/smmu-common.c | 6 +++--- | 15 | hw/arm/raspi.c | 6 ++++-- |
15 | 1 file changed, 3 insertions(+), 3 deletions(-) | 16 | 1 file changed, 4 insertions(+), 2 deletions(-) |
16 | 17 | ||
17 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | 18 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/smmu-common.c | 20 | --- a/hw/arm/raspi.c |
20 | +++ b/hw/arm/smmu-common.c | 21 | +++ b/hw/arm/raspi.c |
21 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) | 22 | @@ -XXX,XX +XXX,XX @@ static void raspi2b_machine_class_init(ObjectClass *oc, void *data) |
22 | SMMUState *s = opaque; | 23 | MachineClass *mc = MACHINE_CLASS(oc); |
23 | SMMUPciBus *sbus = g_hash_table_lookup(s->smmu_pcibus_by_busptr, bus); | 24 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); |
24 | SMMUDevice *sdev; | 25 | |
25 | + static uint index; | 26 | + mc->alias = "raspi2"; |
26 | 27 | rmc->board_rev = 0xa21041; | |
27 | if (!sbus) { | 28 | raspi_machine_class_common_init(mc, rmc->board_rev); |
28 | sbus = g_malloc0(sizeof(SMMUPciBus) + | 29 | }; |
29 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) | 30 | @@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data) |
30 | 31 | MachineClass *mc = MACHINE_CLASS(oc); | |
31 | sdev = sbus->pbdev[devfn]; | 32 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); |
32 | if (!sdev) { | 33 | |
33 | - char *name = g_strdup_printf("%s-%d-%d", | 34 | + mc->alias = "raspi3"; |
34 | - s->mrtypename, | 35 | rmc->board_rev = 0xa02082; |
35 | - pci_bus_num(bus), devfn); | 36 | raspi_machine_class_common_init(mc, rmc->board_rev); |
36 | + char *name = g_strdup_printf("%s-%d-%d", s->mrtypename, devfn, index++); | 37 | }; |
37 | + | 38 | @@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data) |
38 | sdev = sbus->pbdev[devfn] = g_new0(SMMUDevice, 1); | 39 | |
39 | 40 | static const TypeInfo raspi_machine_types[] = { | |
40 | sdev->smmu = s; | 41 | { |
42 | - .name = MACHINE_TYPE_NAME("raspi2"), | ||
43 | + .name = MACHINE_TYPE_NAME("raspi2b"), | ||
44 | .parent = TYPE_RASPI_MACHINE, | ||
45 | .class_init = raspi2b_machine_class_init, | ||
46 | #ifdef TARGET_AARCH64 | ||
47 | }, { | ||
48 | - .name = MACHINE_TYPE_NAME("raspi3"), | ||
49 | + .name = MACHINE_TYPE_NAME("raspi3b"), | ||
50 | .parent = TYPE_RASPI_MACHINE, | ||
51 | .class_init = raspi3b_machine_class_init, | ||
52 | #endif | ||
41 | -- | 53 | -- |
42 | 2.19.0 | 54 | 2.20.1 |
43 | 55 | ||
44 | 56 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 3 | As we only support a reduced set of the REV_CODE_PROCESSOR id |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | encoded in the board revision, define the PROCESSOR_ID values |
5 | Message-id: 20180921161939.822-6-clg@kaod.org | 5 | as an enum. We can simplify the board_soc_type and cores_count |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | methods. |
7 | |||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20200924111808.77168-7-f4bug@amsat.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 12 | --- |
9 | hw/ssi/aspeed_smc.c | 8 ++++---- | 13 | hw/arm/raspi.c | 45 +++++++++++++++++++++------------------------ |
10 | 1 file changed, 4 insertions(+), 4 deletions(-) | 14 | 1 file changed, 21 insertions(+), 24 deletions(-) |
11 | 15 | ||
12 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | 16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/ssi/aspeed_smc.c | 18 | --- a/hw/arm/raspi.c |
15 | +++ b/hw/ssi/aspeed_smc.c | 19 | +++ b/hw/arm/raspi.c |
16 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_flash_default_read(void *opaque, hwaddr addr, | 20 | @@ -XXX,XX +XXX,XX @@ FIELD(REV_CODE, MANUFACTURER, 16, 4); |
17 | static void aspeed_smc_flash_default_write(void *opaque, hwaddr addr, | 21 | FIELD(REV_CODE, MEMORY_SIZE, 20, 3); |
18 | uint64_t data, unsigned size) | 22 | FIELD(REV_CODE, STYLE, 23, 1); |
23 | |||
24 | +typedef enum RaspiProcessorId { | ||
25 | + PROCESSOR_ID_BCM2836 = 1, | ||
26 | + PROCESSOR_ID_BCM2837 = 2, | ||
27 | +} RaspiProcessorId; | ||
28 | + | ||
29 | +static const struct { | ||
30 | + const char *type; | ||
31 | + int cores_count; | ||
32 | +} soc_property[] = { | ||
33 | + [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS}, | ||
34 | + [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS}, | ||
35 | +}; | ||
36 | + | ||
37 | static uint64_t board_ram_size(uint32_t board_rev) | ||
19 | { | 38 | { |
20 | - qemu_log_mask(LOG_GUEST_ERROR, "%s: To 0x%" HWADDR_PRIx " of size %u: 0x%" | 39 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ |
21 | - PRIx64 "\n", __func__, addr, size, data); | 40 | return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE); |
22 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: To 0x%" HWADDR_PRIx " of size %u: 0x%" | ||
23 | + PRIx64 "\n", __func__, addr, size, data); | ||
24 | } | 41 | } |
25 | 42 | ||
26 | static const MemoryRegionOps aspeed_smc_flash_default_ops = { | 43 | -static int board_processor_id(uint32_t board_rev) |
27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_setup(AspeedSMCFlash *fl, uint32_t addr) | 44 | +static RaspiProcessorId board_processor_id(uint32_t board_rev) |
28 | */ | 45 | { |
29 | if (aspeed_smc_flash_mode(fl) == CTRL_FREADMODE) { | 46 | + int proc_id = FIELD_EX32(board_rev, REV_CODE, PROCESSOR); |
30 | for (i = 0; i < aspeed_smc_flash_dummies(fl); i++) { | 47 | + |
31 | - ssi_transfer(fl->controller->spi, 0xFF); | 48 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ |
32 | + ssi_transfer(fl->controller->spi, 0xFF); | 49 | - return FIELD_EX32(board_rev, REV_CODE, PROCESSOR); |
33 | } | 50 | + assert(proc_id < ARRAY_SIZE(soc_property) && soc_property[proc_id].type); |
34 | } | 51 | + |
52 | + return proc_id; | ||
35 | } | 53 | } |
36 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size) | 54 | |
55 | static int board_version(uint32_t board_rev) | ||
56 | @@ -XXX,XX +XXX,XX @@ static int board_version(uint32_t board_rev) | ||
57 | |||
58 | static const char *board_soc_type(uint32_t board_rev) | ||
59 | { | ||
60 | - static const char *soc_types[] = { | ||
61 | - NULL, TYPE_BCM2836, TYPE_BCM2837, | ||
62 | - }; | ||
63 | - int proc_id = board_processor_id(board_rev); | ||
64 | - | ||
65 | - if (proc_id >= ARRAY_SIZE(soc_types) || !soc_types[proc_id]) { | ||
66 | - error_report("Unsupported processor id '%d' (board revision: 0x%x)", | ||
67 | - proc_id, board_rev); | ||
68 | - exit(1); | ||
69 | - } | ||
70 | - return soc_types[proc_id]; | ||
71 | + return soc_property[board_processor_id(board_rev)].type; | ||
37 | } | 72 | } |
38 | 73 | ||
39 | static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data, | 74 | static int cores_count(uint32_t board_rev) |
40 | - unsigned size) | ||
41 | + unsigned size) | ||
42 | { | 75 | { |
43 | AspeedSMCFlash *fl = opaque; | 76 | - static const int soc_cores_count[] = { |
44 | AspeedSMCState *s = fl->controller; | 77 | - 0, BCM283X_NCPUS, BCM283X_NCPUS, |
78 | - }; | ||
79 | - int proc_id = board_processor_id(board_rev); | ||
80 | - | ||
81 | - if (proc_id >= ARRAY_SIZE(soc_cores_count) || !soc_cores_count[proc_id]) { | ||
82 | - error_report("Unsupported processor id '%d' (board revision: 0x%x)", | ||
83 | - proc_id, board_rev); | ||
84 | - exit(1); | ||
85 | - } | ||
86 | - return soc_cores_count[proc_id]; | ||
87 | + return soc_property[board_processor_id(board_rev)].cores_count; | ||
88 | } | ||
89 | |||
90 | static const char *board_type(uint32_t board_rev) | ||
45 | -- | 91 | -- |
46 | 2.19.0 | 92 | 2.20.1 |
47 | 93 | ||
48 | 94 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | aspeed i2c interrupts should be cleared by software only, and the bus | 3 | The firmware load address depends on the SoC ("processor id") used, |
4 | interrupt should be lowered when all interrupts have been cleared. | 4 | not on the version of the board. |
5 | 5 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | Suggested-by: Luc Michel <luc.michel@greensocs.com> |
7 | Message-id: 20180914063506.20815-2-clg@kaod.org | 7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | [PMM: drop TODO comment describing an issue which is | 9 | Message-id: 20200924111808.77168-8-f4bug@amsat.org |
10 | fixed later in the patch series, and clean up commit message] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/i2c/aspeed_i2c.c | 16 ++++++++++++---- | 12 | hw/arm/raspi.c | 3 ++- |
14 | 1 file changed, 12 insertions(+), 4 deletions(-) | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
15 | 14 | ||
16 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | 15 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/i2c/aspeed_i2c.c | 17 | --- a/hw/arm/raspi.c |
19 | +++ b/hw/i2c/aspeed_i2c.c | 18 | +++ b/hw/arm/raspi.c |
20 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
21 | #define I2CD_AC_TIMING_REG2 0x08 /* Clock and AC Timing Control #1 */ | 20 | * the normal Linux boot process |
22 | #define I2CD_INTR_CTRL_REG 0x0c /* I2CD Interrupt Control */ | 21 | */ |
23 | #define I2CD_INTR_STS_REG 0x10 /* I2CD Interrupt Status */ | 22 | if (machine->firmware) { |
24 | + | 23 | - hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2; |
25 | +#define I2CD_INTR_SLAVE_ADDR_MATCH (0x1 << 31) /* 0: addr1 1: addr2 */ | 24 | + hwaddr firmware_addr = processor_id <= PROCESSOR_ID_BCM2836 |
26 | +#define I2CD_INTR_SLAVE_ADDR_RX_PENDING (0x1 << 30) | 25 | + ? FIRMWARE_ADDR_2 : FIRMWARE_ADDR_3; |
27 | +/* bits[19-16] Reserved */ | 26 | /* load the firmware image (typically kernel.img) */ |
28 | + | 27 | r = load_image_targphys(machine->firmware, firmware_addr, |
29 | +/* All bits below are cleared by writing 1 */ | 28 | ram_size - firmware_addr); |
30 | +#define I2CD_INTR_SLAVE_INACTIVE_TIMEOUT (0x1 << 15) | ||
31 | #define I2CD_INTR_SDA_DL_TIMEOUT (0x1 << 14) | ||
32 | #define I2CD_INTR_BUS_RECOVER_DONE (0x1 << 13) | ||
33 | #define I2CD_INTR_SMBUS_ALERT (0x1 << 12) /* Bus [0-3] only */ | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | #define I2CD_INTR_SMBUS_DEV_ALERT_ADDR (0x1 << 10) /* Removed */ | ||
36 | #define I2CD_INTR_SMBUS_DEF_ADDR (0x1 << 9) /* Removed */ | ||
37 | #define I2CD_INTR_GCALL_ADDR (0x1 << 8) /* Removed */ | ||
38 | -#define I2CD_INTR_SLAVE_MATCH (0x1 << 7) /* use RX_DONE */ | ||
39 | +#define I2CD_INTR_SLAVE_ADDR_RX_MATCH (0x1 << 7) /* use RX_DONE */ | ||
40 | #define I2CD_INTR_SCL_TIMEOUT (0x1 << 6) | ||
41 | #define I2CD_INTR_ABNORMAL (0x1 << 5) | ||
42 | #define I2CD_INTR_NORMAL_STOP (0x1 << 4) | ||
43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
44 | { | ||
45 | bus->cmd &= ~0xFFFF; | ||
46 | bus->cmd |= value & 0xFFFF; | ||
47 | - bus->intr_status = 0; | ||
48 | |||
49 | if (bus->cmd & I2CD_M_START_CMD) { | ||
50 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
51 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
52 | break; | ||
53 | case I2CD_INTR_STS_REG: | ||
54 | bus->intr_status &= ~(value & 0x7FFF); | ||
55 | - bus->controller->intr_status &= ~(1 << bus->id); | ||
56 | - qemu_irq_lower(bus->controller->irq); | ||
57 | + if (!bus->intr_status) { | ||
58 | + bus->controller->intr_status &= ~(1 << bus->id); | ||
59 | + qemu_irq_lower(bus->controller->irq); | ||
60 | + } | ||
61 | break; | ||
62 | case I2CD_DEV_ADDR_REG: | ||
63 | qemu_log_mask(LOG_UNIMP, "%s: slave mode not implemented\n", | ||
64 | -- | 29 | -- |
65 | 2.19.0 | 30 | 2.20.1 |
66 | 31 | ||
67 | 32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add 'break' statements missing from a switch in the APB dual-timer | ||
2 | write function. Spotted by Coverity as CID 1395626 and 1395633. | ||
3 | 1 | ||
4 | Reported-by: Paolo Bonzini <pbonzini@redhat.com> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20180924123122.14549-1-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/timer/cmsdk-apb-dualtimer.c | 2 ++ | ||
10 | 1 file changed, 2 insertions(+) | ||
11 | |||
12 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/timer/cmsdk-apb-dualtimer.c | ||
15 | +++ b/hw/timer/cmsdk-apb-dualtimer.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_write(void *opaque, hwaddr offset, | ||
17 | case A_TIMERITCR: | ||
18 | s->timeritcr = value & R_TIMERITCR_VALID_MASK; | ||
19 | cmsdk_apb_dualtimer_update(s); | ||
20 | + break; | ||
21 | case A_TIMERITOP: | ||
22 | s->timeritop = value & R_TIMERITOP_VALID_MASK; | ||
23 | cmsdk_apb_dualtimer_update(s); | ||
24 | + break; | ||
25 | default: | ||
26 | bad_offset: | ||
27 | qemu_log_mask(LOG_GUEST_ERROR, | ||
28 | -- | ||
29 | 2.19.0 | ||
30 | |||
31 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The code looks better, it removes duplicated lines and it will ease | 3 | We expected the 'version' ID to match the board processor ID, |
4 | the introduction of common properties for the Aspeed machines. | 4 | but this is not always true (for example boards with revision |
5 | id 0xa02042/0xa22042 are Raspberry Pi 2 with a BCM2837 SoC). | ||
6 | This was not important because we were not modelling them, but | ||
7 | since the recent refactor now allow to model these boards, it | ||
8 | is safer to check the processor id directly. Remove the version | ||
9 | check. | ||
5 | 10 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 11 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
8 | Message-id: 20180921161939.822-4-clg@kaod.org | 13 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
14 | Message-id: 20200924111808.77168-9-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 16 | --- |
11 | include/hw/arm/aspeed.h | 46 +++++++++ | 17 | hw/arm/raspi.c | 29 +++++++++++++---------------- |
12 | hw/arm/aspeed.c | 212 +++++++++++++--------------------------- | 18 | 1 file changed, 13 insertions(+), 16 deletions(-) |
13 | 2 files changed, 116 insertions(+), 142 deletions(-) | ||
14 | create mode 100644 include/hw/arm/aspeed.h | ||
15 | 19 | ||
16 | diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h | 20 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
17 | new file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/include/hw/arm/aspeed.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +/* | ||
23 | + * Aspeed Machines | ||
24 | + * | ||
25 | + * Copyright 2018 IBM Corp. | ||
26 | + * | ||
27 | + * This code is licensed under the GPL version 2 or later. See | ||
28 | + * the COPYING file in the top-level directory. | ||
29 | + */ | ||
30 | +#ifndef ARM_ASPEED_H | ||
31 | +#define ARM_ASPEED_H | ||
32 | + | ||
33 | +#include "hw/boards.h" | ||
34 | + | ||
35 | +typedef struct AspeedBoardState AspeedBoardState; | ||
36 | + | ||
37 | +typedef struct AspeedBoardConfig { | ||
38 | + const char *name; | ||
39 | + const char *desc; | ||
40 | + const char *soc_name; | ||
41 | + uint32_t hw_strap1; | ||
42 | + const char *fmc_model; | ||
43 | + const char *spi_model; | ||
44 | + uint32_t num_cs; | ||
45 | + void (*i2c_init)(AspeedBoardState *bmc); | ||
46 | +} AspeedBoardConfig; | ||
47 | + | ||
48 | +#define TYPE_ASPEED_MACHINE MACHINE_TYPE_NAME("aspeed") | ||
49 | +#define ASPEED_MACHINE(obj) \ | ||
50 | + OBJECT_CHECK(AspeedMachine, (obj), TYPE_ASPEED_MACHINE) | ||
51 | + | ||
52 | +typedef struct AspeedMachine { | ||
53 | + MachineState parent_obj; | ||
54 | +} AspeedMachine; | ||
55 | + | ||
56 | +#define ASPEED_MACHINE_CLASS(klass) \ | ||
57 | + OBJECT_CLASS_CHECK(AspeedMachineClass, (klass), TYPE_ASPEED_MACHINE) | ||
58 | +#define ASPEED_MACHINE_GET_CLASS(obj) \ | ||
59 | + OBJECT_GET_CLASS(AspeedMachineClass, (obj), TYPE_ASPEED_MACHINE) | ||
60 | + | ||
61 | +typedef struct AspeedMachineClass { | ||
62 | + MachineClass parent_obj; | ||
63 | + const AspeedBoardConfig *board; | ||
64 | +} AspeedMachineClass; | ||
65 | + | ||
66 | + | ||
67 | +#endif | ||
68 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
70 | --- a/hw/arm/aspeed.c | 22 | --- a/hw/arm/raspi.c |
71 | +++ b/hw/arm/aspeed.c | 23 | +++ b/hw/arm/raspi.c |
72 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static RaspiProcessorId board_processor_id(uint32_t board_rev) |
73 | #include "cpu.h" | 25 | return proc_id; |
74 | #include "exec/address-spaces.h" | ||
75 | #include "hw/arm/arm.h" | ||
76 | +#include "hw/arm/aspeed.h" | ||
77 | #include "hw/arm/aspeed_soc.h" | ||
78 | #include "hw/boards.h" | ||
79 | #include "hw/i2c/smbus.h" | ||
80 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedBoardState { | ||
81 | MemoryRegion max_ram; | ||
82 | } AspeedBoardState; | ||
83 | |||
84 | -typedef struct AspeedBoardConfig { | ||
85 | - const char *soc_name; | ||
86 | - uint32_t hw_strap1; | ||
87 | - const char *fmc_model; | ||
88 | - const char *spi_model; | ||
89 | - uint32_t num_cs; | ||
90 | - void (*i2c_init)(AspeedBoardState *bmc); | ||
91 | -} AspeedBoardConfig; | ||
92 | - | ||
93 | -enum { | ||
94 | - PALMETTO_BMC, | ||
95 | - AST2500_EVB, | ||
96 | - ROMULUS_BMC, | ||
97 | - WITHERSPOON_BMC, | ||
98 | -}; | ||
99 | - | ||
100 | /* Palmetto hardware value: 0x120CE416 */ | ||
101 | #define PALMETTO_BMC_HW_STRAP1 ( \ | ||
102 | SCU_AST2400_HW_STRAP_DRAM_SIZE(DRAM_SIZE_256MB) | \ | ||
103 | @@ -XXX,XX +XXX,XX @@ enum { | ||
104 | /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ | ||
105 | #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 | ||
106 | |||
107 | -static void palmetto_bmc_i2c_init(AspeedBoardState *bmc); | ||
108 | -static void ast2500_evb_i2c_init(AspeedBoardState *bmc); | ||
109 | -static void romulus_bmc_i2c_init(AspeedBoardState *bmc); | ||
110 | -static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc); | ||
111 | - | ||
112 | -static const AspeedBoardConfig aspeed_boards[] = { | ||
113 | - [PALMETTO_BMC] = { | ||
114 | - .soc_name = "ast2400-a1", | ||
115 | - .hw_strap1 = PALMETTO_BMC_HW_STRAP1, | ||
116 | - .fmc_model = "n25q256a", | ||
117 | - .spi_model = "mx25l25635e", | ||
118 | - .num_cs = 1, | ||
119 | - .i2c_init = palmetto_bmc_i2c_init, | ||
120 | - }, | ||
121 | - [AST2500_EVB] = { | ||
122 | - .soc_name = "ast2500-a1", | ||
123 | - .hw_strap1 = AST2500_EVB_HW_STRAP1, | ||
124 | - .fmc_model = "w25q256", | ||
125 | - .spi_model = "mx25l25635e", | ||
126 | - .num_cs = 1, | ||
127 | - .i2c_init = ast2500_evb_i2c_init, | ||
128 | - }, | ||
129 | - [ROMULUS_BMC] = { | ||
130 | - .soc_name = "ast2500-a1", | ||
131 | - .hw_strap1 = ROMULUS_BMC_HW_STRAP1, | ||
132 | - .fmc_model = "n25q256a", | ||
133 | - .spi_model = "mx66l1g45g", | ||
134 | - .num_cs = 2, | ||
135 | - .i2c_init = romulus_bmc_i2c_init, | ||
136 | - }, | ||
137 | - [WITHERSPOON_BMC] = { | ||
138 | - .soc_name = "ast2500-a1", | ||
139 | - .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1, | ||
140 | - .fmc_model = "mx25l25635e", | ||
141 | - .spi_model = "mx66l1g45g", | ||
142 | - .num_cs = 2, | ||
143 | - .i2c_init = witherspoon_bmc_i2c_init, | ||
144 | - }, | ||
145 | -}; | ||
146 | - | ||
147 | /* | ||
148 | * The max ram region is for firmwares that scan the address space | ||
149 | * with load/store to guess how much RAM the SoC has. | ||
150 | @@ -XXX,XX +XXX,XX @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) | ||
151 | object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort); | ||
152 | } | 26 | } |
153 | 27 | ||
154 | -static void palmetto_bmc_init(MachineState *machine) | 28 | -static int board_version(uint32_t board_rev) |
155 | -{ | 29 | -{ |
156 | - aspeed_board_init(machine, &aspeed_boards[PALMETTO_BMC]); | 30 | - return board_processor_id(board_rev) + 1; |
157 | -} | 31 | -} |
158 | - | 32 | - |
159 | -static void palmetto_bmc_class_init(ObjectClass *oc, void *data) | 33 | static const char *board_soc_type(uint32_t board_rev) |
160 | -{ | ||
161 | - MachineClass *mc = MACHINE_CLASS(oc); | ||
162 | - | ||
163 | - mc->desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)"; | ||
164 | - mc->init = palmetto_bmc_init; | ||
165 | - mc->max_cpus = 1; | ||
166 | - mc->no_sdcard = 1; | ||
167 | - mc->no_floppy = 1; | ||
168 | - mc->no_cdrom = 1; | ||
169 | - mc->no_parallel = 1; | ||
170 | -} | ||
171 | - | ||
172 | -static const TypeInfo palmetto_bmc_type = { | ||
173 | - .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
174 | - .parent = TYPE_MACHINE, | ||
175 | - .class_init = palmetto_bmc_class_init, | ||
176 | -}; | ||
177 | - | ||
178 | static void ast2500_evb_i2c_init(AspeedBoardState *bmc) | ||
179 | { | 34 | { |
180 | AspeedSoCState *soc = &bmc->soc; | 35 | return soc_property[board_processor_id(board_rev)].type; |
181 | @@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) | 36 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) |
182 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); | 37 | cpu_set_pc(cs, info->smp_loader_start); |
183 | } | 38 | } |
184 | 39 | ||
185 | -static void ast2500_evb_init(MachineState *machine) | 40 | -static void setup_boot(MachineState *machine, int version, size_t ram_size) |
186 | -{ | 41 | +static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, |
187 | - aspeed_board_init(machine, &aspeed_boards[AST2500_EVB]); | 42 | + size_t ram_size) |
188 | -} | ||
189 | - | ||
190 | -static void ast2500_evb_class_init(ObjectClass *oc, void *data) | ||
191 | -{ | ||
192 | - MachineClass *mc = MACHINE_CLASS(oc); | ||
193 | - | ||
194 | - mc->desc = "Aspeed AST2500 EVB (ARM1176)"; | ||
195 | - mc->init = ast2500_evb_init; | ||
196 | - mc->max_cpus = 1; | ||
197 | - mc->no_sdcard = 1; | ||
198 | - mc->no_floppy = 1; | ||
199 | - mc->no_cdrom = 1; | ||
200 | - mc->no_parallel = 1; | ||
201 | -} | ||
202 | - | ||
203 | -static const TypeInfo ast2500_evb_type = { | ||
204 | - .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
205 | - .parent = TYPE_MACHINE, | ||
206 | - .class_init = ast2500_evb_class_init, | ||
207 | -}; | ||
208 | - | ||
209 | static void romulus_bmc_i2c_init(AspeedBoardState *bmc) | ||
210 | { | 43 | { |
211 | AspeedSoCState *soc = &bmc->soc; | 44 | RaspiMachineState *s = RASPI_MACHINE(machine); |
212 | @@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc) | 45 | int r; |
213 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); | 46 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) |
47 | s->binfo.ram_size = ram_size; | ||
48 | s->binfo.nb_cpus = machine->smp.cpus; | ||
49 | |||
50 | - if (version <= 2) { | ||
51 | - /* The rpi1 and 2 require some custom setup code to run in Secure | ||
52 | - * mode before booting a kernel (to set up the SMC vectors so | ||
53 | - * that we get a no-op SMC; this is used by Linux to call the | ||
54 | + if (processor_id <= PROCESSOR_ID_BCM2836) { | ||
55 | + /* | ||
56 | + * The BCM2835 and BCM2836 require some custom setup code to run | ||
57 | + * in Secure mode before booting a kernel (to set up the SMC vectors | ||
58 | + * so that we get a no-op SMC; this is used by Linux to call the | ||
59 | * firmware for some cache maintenance operations. | ||
60 | - * The rpi3 doesn't need this. | ||
61 | + * The BCM2837 doesn't need this. | ||
62 | */ | ||
63 | s->binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
64 | s->binfo.write_board_setup = write_board_setup; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
66 | s->binfo.secure_boot = true; | ||
67 | } | ||
68 | |||
69 | - /* Pi2 and Pi3 requires SMP setup */ | ||
70 | - if (version >= 2) { | ||
71 | + /* BCM2836 and BCM2837 requires SMP setup */ | ||
72 | + if (processor_id >= PROCESSOR_ID_BCM2836) { | ||
73 | s->binfo.smp_loader_start = SMPBOOT_ADDR; | ||
74 | - if (version == 2) { | ||
75 | + if (processor_id == PROCESSOR_ID_BCM2836) { | ||
76 | s->binfo.write_secondary_boot = write_smpboot; | ||
77 | } else { | ||
78 | s->binfo.write_secondary_boot = write_smpboot64; | ||
79 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
80 | RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); | ||
81 | RaspiMachineState *s = RASPI_MACHINE(machine); | ||
82 | uint32_t board_rev = mc->board_rev; | ||
83 | - int version = board_version(board_rev); | ||
84 | uint64_t ram_size = board_ram_size(board_rev); | ||
85 | uint32_t vcram_size; | ||
86 | DriveInfo *di; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
88 | |||
89 | vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size", | ||
90 | &error_abort); | ||
91 | - setup_boot(machine, version, machine->ram_size - vcram_size); | ||
92 | + setup_boot(machine, board_processor_id(mc->board_rev), | ||
93 | + machine->ram_size - vcram_size); | ||
214 | } | 94 | } |
215 | 95 | ||
216 | -static void romulus_bmc_init(MachineState *machine) | 96 | static void raspi_machine_class_common_init(MachineClass *mc, |
217 | -{ | ||
218 | - aspeed_board_init(machine, &aspeed_boards[ROMULUS_BMC]); | ||
219 | -} | ||
220 | - | ||
221 | -static void romulus_bmc_class_init(ObjectClass *oc, void *data) | ||
222 | -{ | ||
223 | - MachineClass *mc = MACHINE_CLASS(oc); | ||
224 | - | ||
225 | - mc->desc = "OpenPOWER Romulus BMC (ARM1176)"; | ||
226 | - mc->init = romulus_bmc_init; | ||
227 | - mc->max_cpus = 1; | ||
228 | - mc->no_sdcard = 1; | ||
229 | - mc->no_floppy = 1; | ||
230 | - mc->no_cdrom = 1; | ||
231 | - mc->no_parallel = 1; | ||
232 | -} | ||
233 | - | ||
234 | -static const TypeInfo romulus_bmc_type = { | ||
235 | - .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
236 | - .parent = TYPE_MACHINE, | ||
237 | - .class_init = romulus_bmc_class_init, | ||
238 | -}; | ||
239 | - | ||
240 | static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
241 | { | ||
242 | AspeedSoCState *soc = &bmc->soc; | ||
243 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
244 | 0x60); | ||
245 | } | ||
246 | |||
247 | -static void witherspoon_bmc_init(MachineState *machine) | ||
248 | +static void aspeed_machine_init(MachineState *machine) | ||
249 | { | ||
250 | - aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]); | ||
251 | + AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); | ||
252 | + | ||
253 | + aspeed_board_init(machine, amc->board); | ||
254 | } | ||
255 | |||
256 | -static void witherspoon_bmc_class_init(ObjectClass *oc, void *data) | ||
257 | +static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
258 | { | ||
259 | MachineClass *mc = MACHINE_CLASS(oc); | ||
260 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
261 | + const AspeedBoardConfig *board = data; | ||
262 | |||
263 | - mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)"; | ||
264 | - mc->init = witherspoon_bmc_init; | ||
265 | + mc->desc = board->desc; | ||
266 | + mc->init = aspeed_machine_init; | ||
267 | mc->max_cpus = 1; | ||
268 | mc->no_sdcard = 1; | ||
269 | mc->no_floppy = 1; | ||
270 | mc->no_cdrom = 1; | ||
271 | mc->no_parallel = 1; | ||
272 | + amc->board = board; | ||
273 | } | ||
274 | |||
275 | -static const TypeInfo witherspoon_bmc_type = { | ||
276 | - .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
277 | +static const TypeInfo aspeed_machine_type = { | ||
278 | + .name = TYPE_ASPEED_MACHINE, | ||
279 | .parent = TYPE_MACHINE, | ||
280 | - .class_init = witherspoon_bmc_class_init, | ||
281 | + .instance_size = sizeof(AspeedMachine), | ||
282 | + .class_size = sizeof(AspeedMachineClass), | ||
283 | + .abstract = true, | ||
284 | }; | ||
285 | |||
286 | -static void aspeed_machine_init(void) | ||
287 | +static const AspeedBoardConfig aspeed_boards[] = { | ||
288 | + { | ||
289 | + .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
290 | + .desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)", | ||
291 | + .soc_name = "ast2400-a1", | ||
292 | + .hw_strap1 = PALMETTO_BMC_HW_STRAP1, | ||
293 | + .fmc_model = "n25q256a", | ||
294 | + .spi_model = "mx25l25635e", | ||
295 | + .num_cs = 1, | ||
296 | + .i2c_init = palmetto_bmc_i2c_init, | ||
297 | + }, { | ||
298 | + .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
299 | + .desc = "Aspeed AST2500 EVB (ARM1176)", | ||
300 | + .soc_name = "ast2500-a1", | ||
301 | + .hw_strap1 = AST2500_EVB_HW_STRAP1, | ||
302 | + .fmc_model = "w25q256", | ||
303 | + .spi_model = "mx25l25635e", | ||
304 | + .num_cs = 1, | ||
305 | + .i2c_init = ast2500_evb_i2c_init, | ||
306 | + }, { | ||
307 | + .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
308 | + .desc = "OpenPOWER Romulus BMC (ARM1176)", | ||
309 | + .soc_name = "ast2500-a1", | ||
310 | + .hw_strap1 = ROMULUS_BMC_HW_STRAP1, | ||
311 | + .fmc_model = "n25q256a", | ||
312 | + .spi_model = "mx66l1g45g", | ||
313 | + .num_cs = 2, | ||
314 | + .i2c_init = romulus_bmc_i2c_init, | ||
315 | + }, { | ||
316 | + .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
317 | + .desc = "OpenPOWER Witherspoon BMC (ARM1176)", | ||
318 | + .soc_name = "ast2500-a1", | ||
319 | + .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1, | ||
320 | + .fmc_model = "mx25l25635e", | ||
321 | + .spi_model = "mx66l1g45g", | ||
322 | + .num_cs = 2, | ||
323 | + .i2c_init = witherspoon_bmc_i2c_init, | ||
324 | + }, | ||
325 | +}; | ||
326 | + | ||
327 | +static void aspeed_machine_types(void) | ||
328 | { | ||
329 | - type_register_static(&palmetto_bmc_type); | ||
330 | - type_register_static(&ast2500_evb_type); | ||
331 | - type_register_static(&romulus_bmc_type); | ||
332 | - type_register_static(&witherspoon_bmc_type); | ||
333 | + int i; | ||
334 | + | ||
335 | + type_register_static(&aspeed_machine_type); | ||
336 | + for (i = 0; i < ARRAY_SIZE(aspeed_boards); ++i) { | ||
337 | + TypeInfo ti = { | ||
338 | + .name = aspeed_boards[i].name, | ||
339 | + .parent = TYPE_ASPEED_MACHINE, | ||
340 | + .class_init = aspeed_machine_class_init, | ||
341 | + .class_data = (void *)&aspeed_boards[i], | ||
342 | + }; | ||
343 | + type_register(&ti); | ||
344 | + } | ||
345 | } | ||
346 | |||
347 | -type_init(aspeed_machine_init) | ||
348 | +type_init(aspeed_machine_types) | ||
349 | -- | 97 | -- |
350 | 2.19.0 | 98 | 2.20.1 |
351 | 99 | ||
352 | 100 | diff view generated by jsdifflib |