1 | ARM bugfixes for rc1... | 1 | Latest run of arm patches -- most of these are Philippe's SD card |
---|---|---|---|
2 | cleanups. I have more in my queue to review, but 32 is enough | ||
3 | patches to warrant sending out. | ||
2 | 4 | ||
5 | thanks | ||
6 | -- PMM | ||
3 | 7 | ||
4 | The following changes since commit f291910db61b5812e68f1e76afb3ade41d567bea: | 8 | The following changes since commit ff8689611a1d954897d857b28f7ef404e11cfa2c: |
5 | 9 | ||
6 | Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-11-09' into staging (2017-11-13 13:13:12 +0000) | 10 | Merge remote-tracking branch 'remotes/mcayland/tags/qemu-openbios-signed' into staging (2018-02-22 11:37:05 +0000) |
7 | 11 | ||
8 | are available in the git repository at: | 12 | are available in the Git repository at: |
9 | 13 | ||
10 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20171113 | 14 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180222 |
11 | 15 | ||
12 | for you to fetch changes up to d25f2a72272b9ffe0d06710d6217d1169bc2cc7d: | 16 | for you to fetch changes up to 4e5cc6756586e967993187657dfcdde4e00288d9: |
13 | 17 | ||
14 | accel/tcg/translate-all: expand cpu_restore_state addr check (2017-11-13 13:55:27 +0000) | 18 | sdcard: simplify SD_SEND_OP_COND (ACMD41) (2018-02-22 15:12:54 +0000) |
15 | 19 | ||
16 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
17 | target-arm queue: | 21 | * New "raspi3" machine emulating RaspberryPi 3 |
18 | * translate-a64.c: silence gcc5 warning | 22 | * Fix bad register definitions for VMIDR and VMPIDR (which caused |
19 | * highbank: validate register offset before access | 23 | assertions for 64-bit guest CPUs with EL2 on big-endian hosts) |
20 | * MAINTAINERS: Add entries for Smartfusion2 | 24 | * hw/char/stm32f2xx_usart: fix TXE/TC bit handling |
21 | * accel/tcg/translate-all: expand cpu_restore_state addr check | 25 | * Fix ast2500 protection register emulation |
22 | (so usermode insn aborts don't crash with an assertion failure) | 26 | * Lots of SD card emulation cleanups and bugfixes |
23 | * fix TCG initialization of some Arm boards by allowing them | ||
24 | to specify min/default number of CPUs to create | ||
25 | 27 | ||
26 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
27 | Alex Bennée (1): | 29 | Hugo Landau (1): |
28 | accel/tcg/translate-all: expand cpu_restore_state addr check | 30 | Fix ast2500 protection register emulation |
29 | 31 | ||
30 | Alistair Francis (2): | 32 | Pekka Enberg (1): |
31 | xlnx-zynqmp: Properly support the smp command line option | 33 | raspi: Add "raspi3" machine type |
32 | xlnx-zcu102: Add an info message deprecating the EP108 | ||
33 | 34 | ||
34 | Emilio G. Cota (4): | 35 | Peter Maydell (1): |
35 | arm/translate-a64: mark path as unreachable to eliminate warning | 36 | target/arm: Fix register definitions for VMIDR and VMPIDR |
36 | qom: move CPUClass.tcg_initialize to a global | ||
37 | xlnx-zcu102: Specify the max number of CPUs for the EP108 | ||
38 | hw: add .min_cpus and .default_cpus fields to machine_class | ||
39 | 37 | ||
40 | Prasad J Pandit (1): | 38 | Philippe Mathieu-Daudé (28): |
41 | highbank: validate register offset before access | 39 | hw/sd/milkymist-memcard: use qemu_log_mask() |
40 | hw/sd/milkymist-memcard: split realize() out of SysBusDevice init() | ||
41 | hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it | ||
42 | hw/sd/ssi-sd: use the SDBus API, connect the SDCard to the bus | ||
43 | sdcard: reorder SDState struct members | ||
44 | sdcard: replace DPRINTF() by trace events | ||
45 | sdcard: add a trace event for command responses | ||
46 | sdcard: replace fprintf() by qemu_hexdump() | ||
47 | sdcard: add more trace events | ||
48 | sdcard: define SDMMC_CMD_MAX instead of using the magic '64' | ||
49 | sdcard: use G_BYTE from cutils | ||
50 | sdcard: use the registerfields API to access the OCR register | ||
51 | sdcard: Don't always set the high capacity bit | ||
52 | sdcard: update the CSD CRC register regardless the CSD structure version | ||
53 | sdcard: fix the 'maximum data transfer rate' to 25MHz | ||
54 | sdcard: clean the SCR register and add few comments | ||
55 | sdcard: remove commands from unsupported old MMC specification | ||
56 | sdcard: simplify using the ldst API | ||
57 | sdcard: use the correct masked OCR in the R3 reply | ||
58 | sdcard: use the registerfields API for the CARD_STATUS register masks | ||
59 | sdcard: handle CMD54 (SDIO) | ||
60 | sdcard: handle the Security Specification commands | ||
61 | sdcard: use a more descriptive label 'unimplemented_spi_cmd' | ||
62 | sdcard: handles more commands in SPI mode | ||
63 | sdcard: check the card is in correct state for APP CMD (CMD55) | ||
64 | sdcard: warn if host uses an incorrect address for APP CMD (CMD55) | ||
65 | sdcard: simplify SEND_IF_COND (CMD8) | ||
66 | sdcard: simplify SD_SEND_OP_COND (ACMD41) | ||
42 | 67 | ||
43 | Subbaraya Sundeep (1): | 68 | Richard Braun (1): |
44 | MAINTAINERS: Add entries for Smartfusion2 | 69 | hw/char/stm32f2xx_usart: fix TXE/TC bit handling |
45 | 70 | ||
46 | include/exec/exec-all.h | 11 ++++++++++ | 71 | hw/sd/sdmmc-internal.h | 15 ++ |
47 | include/hw/boards.h | 5 +++++ | 72 | include/hw/char/stm32f2xx_usart.h | 7 +- |
48 | include/qom/cpu.h | 1 - | 73 | include/hw/sd/sd.h | 1 - |
49 | accel/tcg/translate-all.c | 52 ++++++++++++++++++++++++++-------------------- | 74 | hw/arm/raspi.c | 23 ++ |
50 | exec.c | 5 +++-- | 75 | hw/char/stm32f2xx_usart.c | 12 +- |
51 | hw/arm/exynos4_boards.c | 12 ++++------- | 76 | hw/misc/aspeed_scu.c | 6 +- |
52 | hw/arm/highbank.c | 17 +++++++++++++-- | 77 | hw/misc/aspeed_sdmc.c | 8 +- |
53 | hw/arm/raspi.c | 2 ++ | 78 | hw/sd/milkymist-memcard.c | 87 +++---- |
54 | hw/arm/xlnx-zcu102.c | 9 +++++++- | 79 | hw/sd/sd.c | 467 +++++++++++++++++++++++--------------- |
55 | hw/arm/xlnx-zynqmp.c | 26 ++++++++++++++--------- | 80 | hw/sd/ssi-sd.c | 32 +-- |
56 | target/arm/translate-a64.c | 2 ++ | 81 | target/arm/helper.c | 8 +- |
57 | vl.c | 21 ++++++++++++++++--- | 82 | hw/sd/trace-events | 20 ++ |
58 | MAINTAINERS | 17 +++++++++++++++ | 83 | 12 files changed, 446 insertions(+), 240 deletions(-) |
59 | qemu-doc.texi | 7 +++++++ | 84 | create mode 100644 hw/sd/sdmmc-internal.h |
60 | 14 files changed, 137 insertions(+), 50 deletions(-) | ||
61 | 85 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The register definitions for VMIDR and VMPIDR have separate | ||
2 | reginfo structs for the AArch32 and AArch64 registers. However | ||
3 | the 32-bit versions are wrong: | ||
4 | * they use offsetof instead of offsetoflow32 to mark where | ||
5 | the 32-bit value lives in the uint64_t CPU state field | ||
6 | * they don't mark themselves as ARM_CP_ALIAS | ||
1 | 7 | ||
8 | In particular this means that if you try to use an Arm guest CPU | ||
9 | which enables EL2 on a big-endian host it will assert at reset: | ||
10 | target/arm/cpu.c:114: cp_reg_check_reset: Assertion `oldvalue == newvalue' failed. | ||
11 | |||
12 | because the reset of the 32-bit register writes to the top | ||
13 | half of the uint64_t. | ||
14 | |||
15 | Correct the errors in the structures. | ||
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
19 | --- | ||
20 | This is necessary for 'make check' to pass on big endian | ||
21 | systems with the 'raspi3' board enabled, which is the | ||
22 | first board which has an EL2-enabled-by-default CPU. | ||
23 | --- | ||
24 | target/arm/helper.c | 8 ++++---- | ||
25 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
26 | |||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
32 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | ||
33 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
34 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
35 | - .resetvalue = cpu->midr, | ||
36 | - .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
37 | + .resetvalue = cpu->midr, .type = ARM_CP_ALIAS, | ||
38 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, | ||
39 | { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
40 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
41 | .access = PL2_RW, .resetvalue = cpu->midr, | ||
42 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
43 | { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, | ||
44 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
45 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
46 | - .resetvalue = vmpidr_def, | ||
47 | - .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
48 | + .resetvalue = vmpidr_def, .type = ARM_CP_ALIAS, | ||
49 | + .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, | ||
50 | { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
51 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
52 | .access = PL2_RW, | ||
53 | -- | ||
54 | 2.16.1 | ||
55 | |||
56 | diff view generated by jsdifflib |
1 | From: "Emilio G. Cota" <cota@braap.org> | 1 | From: Pekka Enberg <penberg@iki.fi> |
---|---|---|---|
2 | 2 | ||
3 | max_cpus needs to be an upper bound on the number of vCPUs | 3 | This patch adds a "raspi3" machine type, which can now be selected as |
4 | initialized; otherwise TCG region initialization breaks. | 4 | the machine to run on by users via the "-M" command line option to QEMU. |
5 | 5 | ||
6 | Some boards initialize a hard-coded number of vCPUs, which is not | 6 | The machine type does *not* ignore memory transaction failures so we |
7 | captured by the global max_cpus and therefore breaks TCG initialization. | 7 | likely need to add some dummy devices later when people run something |
8 | Fix it by adding the .min_cpus field to machine_class. | 8 | more complicated than what I'm using for testing. |
9 | 9 | ||
10 | This commit also changes some user-facing behaviour: we now die if | 10 | Signed-off-by: Pekka Enberg <penberg@iki.fi> |
11 | -smp is below this hard-coded vCPU minimum instead of silently | 11 | [PMM: added #ifdef TARGET_AARCH64 so we don't provide the 64-bit |
12 | ignoring the passed -smp value (sometimes announcing this by printing | 12 | board in the 32-bit only arm-softmmu build.] |
13 | a warning). However, the introduction of .default_cpus lessens the | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | likelihood that users will notice this: if -smp isn't set, we now | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | assign the value in .default_cpus to both smp_cpus and max_cpus. IOW, | ||
16 | if a user does not set -smp, they always get a correct number of vCPUs. | ||
17 | |||
18 | This change fixes 3468b59 ("tcg: enable multiple TCG contexts in | ||
19 | softmmu", 2017-10-24), which broke TCG initialization for some | ||
20 | ARM boards. | ||
21 | |||
22 | Fixes: 3468b59e18b179bc63c7ce934de912dfa9596122 | ||
23 | Reported-by: Thomas Huth <thuth@redhat.com> | ||
24 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
25 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
26 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
27 | Message-id: 1510343626-25861-6-git-send-email-cota@braap.org | ||
28 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 16 | --- |
32 | include/hw/boards.h | 5 +++++ | 17 | hw/arm/raspi.c | 23 +++++++++++++++++++++++ |
33 | hw/arm/exynos4_boards.c | 12 ++++-------- | 18 | 1 file changed, 23 insertions(+) |
34 | hw/arm/raspi.c | 2 ++ | ||
35 | hw/arm/xlnx-zcu102.c | 2 ++ | ||
36 | vl.c | 21 ++++++++++++++++++--- | ||
37 | 5 files changed, 31 insertions(+), 11 deletions(-) | ||
38 | 19 | ||
39 | diff --git a/include/hw/boards.h b/include/hw/boards.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/include/hw/boards.h | ||
42 | +++ b/include/hw/boards.h | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
44 | |||
45 | /** | ||
46 | * MachineClass: | ||
47 | + * @max_cpus: maximum number of CPUs supported. Default: 1 | ||
48 | + * @min_cpus: minimum number of CPUs supported. Default: 1 | ||
49 | + * @default_cpus: number of CPUs instantiated if none are specified. Default: 1 | ||
50 | * @get_hotplug_handler: this function is called during bus-less | ||
51 | * device hotplug. If defined it returns pointer to an instance | ||
52 | * of HotplugHandler object, which handles hotplug operation | ||
53 | @@ -XXX,XX +XXX,XX @@ struct MachineClass { | ||
54 | BlockInterfaceType block_default_type; | ||
55 | int units_per_default_bus; | ||
56 | int max_cpus; | ||
57 | + int min_cpus; | ||
58 | + int default_cpus; | ||
59 | unsigned int no_serial:1, | ||
60 | no_parallel:1, | ||
61 | use_virtcon:1, | ||
62 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/arm/exynos4_boards.c | ||
65 | +++ b/hw/arm/exynos4_boards.c | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | #include "qemu-common.h" | ||
68 | #include "cpu.h" | ||
69 | #include "sysemu/sysemu.h" | ||
70 | -#include "sysemu/qtest.h" | ||
71 | #include "hw/sysbus.h" | ||
72 | #include "net/net.h" | ||
73 | #include "hw/arm/arm.h" | ||
74 | @@ -XXX,XX +XXX,XX @@ exynos4_boards_init_common(MachineState *machine, | ||
75 | Exynos4BoardType board_type) | ||
76 | { | ||
77 | Exynos4BoardState *s = g_new(Exynos4BoardState, 1); | ||
78 | - MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
79 | - | ||
80 | - if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) { | ||
81 | - error_report("%s board supports only %d CPU cores, ignoring smp_cpus" | ||
82 | - " value", | ||
83 | - mc->name, EXYNOS4210_NCPUS); | ||
84 | - } | ||
85 | |||
86 | exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type]; | ||
87 | exynos4_board_binfo.board_id = exynos4_board_id[board_type]; | ||
88 | @@ -XXX,XX +XXX,XX @@ static void nuri_class_init(ObjectClass *oc, void *data) | ||
89 | mc->desc = "Samsung NURI board (Exynos4210)"; | ||
90 | mc->init = nuri_init; | ||
91 | mc->max_cpus = EXYNOS4210_NCPUS; | ||
92 | + mc->min_cpus = EXYNOS4210_NCPUS; | ||
93 | + mc->default_cpus = EXYNOS4210_NCPUS; | ||
94 | mc->ignore_memory_transaction_failures = true; | ||
95 | } | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static void smdkc210_class_init(ObjectClass *oc, void *data) | ||
98 | mc->desc = "Samsung SMDKC210 board (Exynos4210)"; | ||
99 | mc->init = smdkc210_init; | ||
100 | mc->max_cpus = EXYNOS4210_NCPUS; | ||
101 | + mc->min_cpus = EXYNOS4210_NCPUS; | ||
102 | + mc->default_cpus = EXYNOS4210_NCPUS; | ||
103 | mc->ignore_memory_transaction_failures = true; | ||
104 | } | ||
105 | |||
106 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 20 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c |
107 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
108 | --- a/hw/arm/raspi.c | 22 | --- a/hw/arm/raspi.c |
109 | +++ b/hw/arm/raspi.c | 23 | +++ b/hw/arm/raspi.c |
110 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | 24 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) |
111 | mc->no_floppy = 1; | 25 | mc->ignore_memory_transaction_failures = true; |
112 | mc->no_cdrom = 1; | 26 | }; |
113 | mc->max_cpus = BCM2836_NCPUS; | 27 | DEFINE_MACHINE("raspi2", raspi2_machine_init) |
28 | + | ||
29 | +#ifdef TARGET_AARCH64 | ||
30 | +static void raspi3_init(MachineState *machine) | ||
31 | +{ | ||
32 | + raspi_init(machine, 3); | ||
33 | +} | ||
34 | + | ||
35 | +static void raspi3_machine_init(MachineClass *mc) | ||
36 | +{ | ||
37 | + mc->desc = "Raspberry Pi 3"; | ||
38 | + mc->init = raspi3_init; | ||
39 | + mc->block_default_type = IF_SD; | ||
40 | + mc->no_parallel = 1; | ||
41 | + mc->no_floppy = 1; | ||
42 | + mc->no_cdrom = 1; | ||
43 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | ||
44 | + mc->max_cpus = BCM2836_NCPUS; | ||
114 | + mc->min_cpus = BCM2836_NCPUS; | 45 | + mc->min_cpus = BCM2836_NCPUS; |
115 | + mc->default_cpus = BCM2836_NCPUS; | 46 | + mc->default_cpus = BCM2836_NCPUS; |
116 | mc->default_ram_size = 1024 * 1024 * 1024; | 47 | + mc->default_ram_size = 1024 * 1024 * 1024; |
117 | mc->ignore_memory_transaction_failures = true; | 48 | +} |
118 | }; | 49 | +DEFINE_MACHINE("raspi3", raspi3_machine_init) |
119 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | 50 | +#endif |
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/hw/arm/xlnx-zcu102.c | ||
122 | +++ b/hw/arm/xlnx-zcu102.c | ||
123 | @@ -XXX,XX +XXX,XX @@ static void xlnx_ep108_machine_class_init(ObjectClass *oc, void *data) | ||
124 | mc->units_per_default_bus = 1; | ||
125 | mc->ignore_memory_transaction_failures = true; | ||
126 | mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS; | ||
127 | + mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS; | ||
128 | } | ||
129 | |||
130 | static const TypeInfo xlnx_ep108_machine_init_typeinfo = { | ||
131 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data) | ||
132 | mc->units_per_default_bus = 1; | ||
133 | mc->ignore_memory_transaction_failures = true; | ||
134 | mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS; | ||
135 | + mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS; | ||
136 | } | ||
137 | |||
138 | static const TypeInfo xlnx_zcu102_machine_init_typeinfo = { | ||
139 | diff --git a/vl.c b/vl.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/vl.c | ||
142 | +++ b/vl.c | ||
143 | @@ -XXX,XX +XXX,XX @@ Chardev *virtcon_hds[MAX_VIRTIO_CONSOLES]; | ||
144 | Chardev *sclp_hds[MAX_SCLP_CONSOLES]; | ||
145 | int win2k_install_hack = 0; | ||
146 | int singlestep = 0; | ||
147 | -int smp_cpus = 1; | ||
148 | -unsigned int max_cpus = 1; | ||
149 | +int smp_cpus; | ||
150 | +unsigned int max_cpus; | ||
151 | int smp_cores = 1; | ||
152 | int smp_threads = 1; | ||
153 | int acpi_enabled = 1; | ||
154 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) | ||
155 | exit(0); | ||
156 | } | ||
157 | |||
158 | + /* machine_class: default to UP */ | ||
159 | + machine_class->max_cpus = machine_class->max_cpus ?: 1; | ||
160 | + machine_class->min_cpus = machine_class->min_cpus ?: 1; | ||
161 | + machine_class->default_cpus = machine_class->default_cpus ?: 1; | ||
162 | + | ||
163 | + /* default to machine_class->default_cpus */ | ||
164 | + smp_cpus = machine_class->default_cpus; | ||
165 | + max_cpus = machine_class->default_cpus; | ||
166 | + | ||
167 | smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); | ||
168 | |||
169 | - machine_class->max_cpus = machine_class->max_cpus ?: 1; /* Default to UP */ | ||
170 | + /* sanity-check smp_cpus and max_cpus against machine_class */ | ||
171 | + if (smp_cpus < machine_class->min_cpus) { | ||
172 | + error_report("Invalid SMP CPUs %d. The min CPUs " | ||
173 | + "supported by machine '%s' is %d", smp_cpus, | ||
174 | + machine_class->name, machine_class->min_cpus); | ||
175 | + exit(1); | ||
176 | + } | ||
177 | if (max_cpus > machine_class->max_cpus) { | ||
178 | error_report("Invalid SMP CPUs %d. The max CPUs " | ||
179 | "supported by machine '%s' is %d", max_cpus, | ||
180 | -- | 51 | -- |
181 | 2.7.4 | 52 | 2.16.1 |
182 | 53 | ||
183 | 54 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Braun <rbraun@sceen.net> | ||
1 | 2 | ||
3 | I/O currently being synchronous, there is no reason to ever clear the | ||
4 | SR_TXE bit. However the SR_TC bit may be cleared by software writing | ||
5 | to the SR register, so set it on each write. | ||
6 | |||
7 | In addition, fix the reset value of the USART status register. | ||
8 | |||
9 | Signed-off-by: Richard Braun <rbraun@sceen.net> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
11 | [PMM: removed XXX tag from comment, since it isn't something | ||
12 | we need to come back and fix in QEMU] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | include/hw/char/stm32f2xx_usart.h | 7 ++++++- | ||
16 | hw/char/stm32f2xx_usart.c | 12 ++++++++---- | ||
17 | 2 files changed, 14 insertions(+), 5 deletions(-) | ||
18 | |||
19 | diff --git a/include/hw/char/stm32f2xx_usart.h b/include/hw/char/stm32f2xx_usart.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/hw/char/stm32f2xx_usart.h | ||
22 | +++ b/include/hw/char/stm32f2xx_usart.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #define USART_CR3 0x14 | ||
25 | #define USART_GTPR 0x18 | ||
26 | |||
27 | -#define USART_SR_RESET 0x00C00000 | ||
28 | +/* | ||
29 | + * NB: The reset value mentioned in "24.6.1 Status register" seems bogus. | ||
30 | + * Looking at "Table 98 USART register map and reset values", it seems it | ||
31 | + * should be 0xc0, and that's how real hardware behaves. | ||
32 | + */ | ||
33 | +#define USART_SR_RESET (USART_SR_TXE | USART_SR_TC) | ||
34 | |||
35 | #define USART_SR_TXE (1 << 7) | ||
36 | #define USART_SR_TC (1 << 6) | ||
37 | diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/char/stm32f2xx_usart.c | ||
40 | +++ b/hw/char/stm32f2xx_usart.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, | ||
42 | switch (addr) { | ||
43 | case USART_SR: | ||
44 | retvalue = s->usart_sr; | ||
45 | - s->usart_sr &= ~USART_SR_TC; | ||
46 | qemu_chr_fe_accept_input(&s->chr); | ||
47 | return retvalue; | ||
48 | case USART_DR: | ||
49 | DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); | ||
50 | - s->usart_sr |= USART_SR_TXE; | ||
51 | s->usart_sr &= ~USART_SR_RXNE; | ||
52 | qemu_chr_fe_accept_input(&s->chr); | ||
53 | qemu_set_irq(s->irq, 0); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr, | ||
55 | switch (addr) { | ||
56 | case USART_SR: | ||
57 | if (value <= 0x3FF) { | ||
58 | - s->usart_sr = value; | ||
59 | + /* I/O being synchronous, TXE is always set. In addition, it may | ||
60 | + only be set by hardware, so keep it set here. */ | ||
61 | + s->usart_sr = value | USART_SR_TXE; | ||
62 | } else { | ||
63 | s->usart_sr &= value; | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_usart_write(void *opaque, hwaddr addr, | ||
66 | /* XXX this blocks entire thread. Rewrite to use | ||
67 | * qemu_chr_fe_write and background I/O callbacks */ | ||
68 | qemu_chr_fe_write_all(&s->chr, &ch, 1); | ||
69 | + /* XXX I/O are currently synchronous, making it impossible for | ||
70 | + software to observe transient states where TXE or TC aren't | ||
71 | + set. Unlike TXE however, which is read-only, software may | ||
72 | + clear TC by writing 0 to the SR register, so set it again | ||
73 | + on each write. */ | ||
74 | s->usart_sr |= USART_SR_TC; | ||
75 | - s->usart_sr &= ~USART_SR_TXE; | ||
76 | } | ||
77 | return; | ||
78 | case USART_BRR: | ||
79 | -- | ||
80 | 2.16.1 | ||
81 | |||
82 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Hugo Landau <hlandau@devever.net> | ||
1 | 2 | ||
3 | Some register blocks of the ast2500 are protected by protection key | ||
4 | registers which require the right magic value to be written to those | ||
5 | registers to allow those registers to be mutated. | ||
6 | |||
7 | Register manuals indicate that writing the correct magic value to these | ||
8 | registers should cause subsequent reads from those values to return 1, | ||
9 | and writing any other value should cause subsequent reads to return 0. | ||
10 | |||
11 | Previously, qemu implemented these registers incorrectly: the registers | ||
12 | were handled as simple memory, meaning that writing some value x to a | ||
13 | protection key register would result in subsequent reads from that | ||
14 | register returning the same value x. The protection was implemented by | ||
15 | ensuring that the current value of that register equaled the magic | ||
16 | value. | ||
17 | |||
18 | This modifies qemu to have the correct behaviour: attempts to write to a | ||
19 | ast2500 protection register results in a transition to 1 or 0 depending | ||
20 | on whether the written value is the correct magic. The protection logic | ||
21 | is updated to ensure that the value of the register is nonzero. | ||
22 | |||
23 | This bug caused deadlocks with u-boot HEAD: when u-boot is done with a | ||
24 | protectable register block, it attempts to lock it by writing the | ||
25 | bitwise inverse of the correct magic value, and then spinning forever | ||
26 | until the register reads as zero. Since qemu implemented writes to these | ||
27 | registers as ordinary memory writes, writing the inverse of the magic | ||
28 | value resulted in subsequent reads returning that value, leading to | ||
29 | u-boot spinning forever. | ||
30 | |||
31 | Signed-off-by: Hugo Landau <hlandau@devever.net> | ||
32 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
33 | Acked-by: Andrew Jeffery <andrew@aj.id.au> | ||
34 | Message-id: 20180220132627.4163-1-hlandau@devever.net | ||
35 | [PMM: fixed incorrect code indentation] | ||
36 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
37 | --- | ||
38 | hw/misc/aspeed_scu.c | 6 +++++- | ||
39 | hw/misc/aspeed_sdmc.c | 8 +++++++- | ||
40 | 2 files changed, 12 insertions(+), 2 deletions(-) | ||
41 | |||
42 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/misc/aspeed_scu.c | ||
45 | +++ b/hw/misc/aspeed_scu.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
47 | } | ||
48 | |||
49 | if (reg > PROT_KEY && reg < CPU2_BASE_SEG1 && | ||
50 | - s->regs[PROT_KEY] != ASPEED_SCU_PROT_KEY) { | ||
51 | + !s->regs[PROT_KEY]) { | ||
52 | qemu_log_mask(LOG_GUEST_ERROR, "%s: SCU is locked!\n", __func__); | ||
53 | return; | ||
54 | } | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
56 | trace_aspeed_scu_write(offset, size, data); | ||
57 | |||
58 | switch (reg) { | ||
59 | + case PROT_KEY: | ||
60 | + s->regs[reg] = (data == ASPEED_SCU_PROT_KEY) ? 1 : 0; | ||
61 | + return; | ||
62 | + | ||
63 | case FREQ_CNTR_EVAL: | ||
64 | case VGA_SCRATCH1 ... VGA_SCRATCH8: | ||
65 | case RNG_DATA: | ||
66 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/misc/aspeed_sdmc.c | ||
69 | +++ b/hw/misc/aspeed_sdmc.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | - if (addr != R_PROT && s->regs[R_PROT] != PROT_KEY_UNLOCK) { | ||
75 | + if (addr == R_PROT) { | ||
76 | + s->regs[addr] = (data == PROT_KEY_UNLOCK) ? 1 : 0; | ||
77 | + return; | ||
78 | + } | ||
79 | + | ||
80 | + if (!s->regs[R_PROT]) { | ||
81 | qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__); | ||
82 | return; | ||
83 | } | ||
84 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | ||
85 | data &= ~ASPEED_SDMC_READONLY_MASK; | ||
86 | break; | ||
87 | case AST2500_A0_SILICON_REV: | ||
88 | + case AST2500_A1_SILICON_REV: | ||
89 | data &= ~ASPEED_SDMC_AST2500_READONLY_MASK; | ||
90 | break; | ||
91 | default: | ||
92 | -- | ||
93 | 2.16.1 | ||
94 | |||
95 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Acked-by: Michael Walle <michael@walle.cc> | ||
6 | Message-id: 20180216022933.10945-2-f4bug@amsat.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/sd/milkymist-memcard.c | 17 ++++++++++------- | ||
10 | 1 file changed, 10 insertions(+), 7 deletions(-) | ||
11 | |||
12 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/sd/milkymist-memcard.c | ||
15 | +++ b/hw/sd/milkymist-memcard.c | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | */ | ||
18 | |||
19 | #include "qemu/osdep.h" | ||
20 | +#include "qemu/log.h" | ||
21 | #include "hw/hw.h" | ||
22 | #include "hw/sysbus.h" | ||
23 | #include "sysemu/sysemu.h" | ||
24 | #include "trace.h" | ||
25 | -#include "qemu/error-report.h" | ||
26 | +#include "include/qapi/error.h" | ||
27 | #include "sysemu/block-backend.h" | ||
28 | #include "sysemu/blockdev.h" | ||
29 | #include "hw/sd/sd.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr, | ||
31 | } else { | ||
32 | r = s->response[s->response_read_ptr++]; | ||
33 | if (s->response_read_ptr > s->response_len) { | ||
34 | - error_report("milkymist_memcard: " | ||
35 | - "read more cmd bytes than available. Clipping."); | ||
36 | + qemu_log_mask(LOG_GUEST_ERROR, "milkymist_memcard: " | ||
37 | + "read more cmd bytes than available. Clipping."); | ||
38 | s->response_read_ptr = 0; | ||
39 | } | ||
40 | } | ||
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr, | ||
42 | break; | ||
43 | |||
44 | default: | ||
45 | - error_report("milkymist_memcard: read access to unknown register 0x" | ||
46 | - TARGET_FMT_plx, addr << 2); | ||
47 | + qemu_log_mask(LOG_UNIMP, "milkymist_memcard: " | ||
48 | + "read access to unknown register 0x%" HWADDR_PRIx "\n", | ||
49 | + addr << 2); | ||
50 | break; | ||
51 | } | ||
52 | |||
53 | @@ -XXX,XX +XXX,XX @@ static void memcard_write(void *opaque, hwaddr addr, uint64_t value, | ||
54 | break; | ||
55 | |||
56 | default: | ||
57 | - error_report("milkymist_memcard: write access to unknown register 0x" | ||
58 | - TARGET_FMT_plx, addr << 2); | ||
59 | + qemu_log_mask(LOG_UNIMP, "milkymist_memcard: " | ||
60 | + "write access to unknown register 0x%" HWADDR_PRIx " " | ||
61 | + "(value 0x%" PRIx64 ")\n", addr << 2, value); | ||
62 | break; | ||
63 | } | ||
64 | } | ||
65 | -- | ||
66 | 2.16.1 | ||
67 | |||
68 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Create the SDCard in the realize() function. | ||
4 | |||
5 | Suggested-by: Michael Walle <michael@walle.cc> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
8 | Acked-by: Michael Walle <michael@walle.cc> | ||
9 | Message-id: 20180216022933.10945-3-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/sd/milkymist-memcard.c | 28 ++++++++++++++++------------ | ||
13 | 1 file changed, 16 insertions(+), 12 deletions(-) | ||
14 | |||
15 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/sd/milkymist-memcard.c | ||
18 | +++ b/hw/sd/milkymist-memcard.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_reset(DeviceState *d) | ||
20 | device_reset(DEVICE(s->card)); | ||
21 | } | ||
22 | |||
23 | -static int milkymist_memcard_init(SysBusDevice *dev) | ||
24 | +static void milkymist_memcard_init(Object *obj) | ||
25 | +{ | ||
26 | + MilkymistMemcardState *s = MILKYMIST_MEMCARD(obj); | ||
27 | + SysBusDevice *dev = SYS_BUS_DEVICE(obj); | ||
28 | + | ||
29 | + memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s, | ||
30 | + "milkymist-memcard", R_MAX * 4); | ||
31 | + sysbus_init_mmio(dev, &s->regs_region); | ||
32 | +} | ||
33 | + | ||
34 | +static void milkymist_memcard_realize(DeviceState *dev, Error **errp) | ||
35 | { | ||
36 | MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev); | ||
37 | - DriveInfo *dinfo; | ||
38 | BlockBackend *blk; | ||
39 | + DriveInfo *dinfo; | ||
40 | |||
41 | /* FIXME use a qdev drive property instead of drive_get_next() */ | ||
42 | dinfo = drive_get_next(IF_SD); | ||
43 | blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; | ||
44 | s->card = sd_init(blk, false); | ||
45 | if (s->card == NULL) { | ||
46 | - return -1; | ||
47 | + error_setg(errp, "failed to init SD card"); | ||
48 | + return; | ||
49 | } | ||
50 | - | ||
51 | s->enabled = blk && blk_is_inserted(blk); | ||
52 | - | ||
53 | - memory_region_init_io(&s->regs_region, OBJECT(s), &memcard_mmio_ops, s, | ||
54 | - "milkymist-memcard", R_MAX * 4); | ||
55 | - sysbus_init_mmio(dev, &s->regs_region); | ||
56 | - | ||
57 | - return 0; | ||
58 | } | ||
59 | |||
60 | static const VMStateDescription vmstate_milkymist_memcard = { | ||
61 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_milkymist_memcard = { | ||
62 | static void milkymist_memcard_class_init(ObjectClass *klass, void *data) | ||
63 | { | ||
64 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
65 | - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | ||
66 | |||
67 | - k->init = milkymist_memcard_init; | ||
68 | + dc->realize = milkymist_memcard_realize; | ||
69 | dc->reset = milkymist_memcard_reset; | ||
70 | dc->vmsd = &vmstate_milkymist_memcard; | ||
71 | /* Reason: init() method uses drive_get_next() */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo milkymist_memcard_info = { | ||
73 | .name = TYPE_MILKYMIST_MEMCARD, | ||
74 | .parent = TYPE_SYS_BUS_DEVICE, | ||
75 | .instance_size = sizeof(MilkymistMemcardState), | ||
76 | + .instance_init = milkymist_memcard_init, | ||
77 | .class_init = milkymist_memcard_class_init, | ||
78 | }; | ||
79 | |||
80 | -- | ||
81 | 2.16.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | using the sdbus_*() API. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Acked-by: Michael Walle <michael@walle.cc> | ||
8 | Message-id: 20180216022933.10945-4-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/sd/milkymist-memcard.c | 38 +++++++++++++++++++++----------------- | ||
12 | 1 file changed, 21 insertions(+), 17 deletions(-) | ||
13 | |||
14 | diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/sd/milkymist-memcard.c | ||
17 | +++ b/hw/sd/milkymist-memcard.c | ||
18 | @@ -XXX,XX +XXX,XX @@ struct MilkymistMemcardState { | ||
19 | SysBusDevice parent_obj; | ||
20 | |||
21 | MemoryRegion regs_region; | ||
22 | - SDState *card; | ||
23 | + SDBus sdbus; | ||
24 | |||
25 | int command_write_ptr; | ||
26 | int response_read_ptr; | ||
27 | @@ -XXX,XX +XXX,XX @@ static void memcard_sd_command(MilkymistMemcardState *s) | ||
28 | req.crc = s->command[5]; | ||
29 | |||
30 | s->response[0] = req.cmd; | ||
31 | - s->response_len = sd_do_command(s->card, &req, s->response+1); | ||
32 | + s->response_len = sdbus_do_command(&s->sdbus, &req, s->response + 1); | ||
33 | s->response_read_ptr = 0; | ||
34 | |||
35 | if (s->response_len == 16) { | ||
36 | @@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr, | ||
37 | r = 0xffffffff; | ||
38 | } else { | ||
39 | r = 0; | ||
40 | - r |= sd_read_data(s->card) << 24; | ||
41 | - r |= sd_read_data(s->card) << 16; | ||
42 | - r |= sd_read_data(s->card) << 8; | ||
43 | - r |= sd_read_data(s->card); | ||
44 | + r |= sdbus_read_data(&s->sdbus) << 24; | ||
45 | + r |= sdbus_read_data(&s->sdbus) << 16; | ||
46 | + r |= sdbus_read_data(&s->sdbus) << 8; | ||
47 | + r |= sdbus_read_data(&s->sdbus); | ||
48 | } | ||
49 | break; | ||
50 | case R_CLK2XDIV: | ||
51 | @@ -XXX,XX +XXX,XX @@ static void memcard_write(void *opaque, hwaddr addr, uint64_t value, | ||
52 | if (!s->enabled) { | ||
53 | break; | ||
54 | } | ||
55 | - sd_write_data(s->card, (value >> 24) & 0xff); | ||
56 | - sd_write_data(s->card, (value >> 16) & 0xff); | ||
57 | - sd_write_data(s->card, (value >> 8) & 0xff); | ||
58 | - sd_write_data(s->card, value & 0xff); | ||
59 | + sdbus_write_data(&s->sdbus, (value >> 24) & 0xff); | ||
60 | + sdbus_write_data(&s->sdbus, (value >> 16) & 0xff); | ||
61 | + sdbus_write_data(&s->sdbus, (value >> 8) & 0xff); | ||
62 | + sdbus_write_data(&s->sdbus, value & 0xff); | ||
63 | break; | ||
64 | case R_ENABLE: | ||
65 | s->regs[addr] = value; | ||
66 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_reset(DeviceState *d) | ||
67 | for (i = 0; i < R_MAX; i++) { | ||
68 | s->regs[i] = 0; | ||
69 | } | ||
70 | - /* Since we're still using the legacy SD API the card is not plugged | ||
71 | - * into any bus, and we must reset it manually. | ||
72 | - */ | ||
73 | - device_reset(DEVICE(s->card)); | ||
74 | } | ||
75 | |||
76 | static void milkymist_memcard_init(Object *obj) | ||
77 | @@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_init(Object *obj) | ||
78 | static void milkymist_memcard_realize(DeviceState *dev, Error **errp) | ||
79 | { | ||
80 | MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev); | ||
81 | + DeviceState *carddev; | ||
82 | BlockBackend *blk; | ||
83 | DriveInfo *dinfo; | ||
84 | + Error *err = NULL; | ||
85 | |||
86 | + qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, | ||
87 | + dev, "sd-bus"); | ||
88 | + | ||
89 | + /* Create and plug in the sd card */ | ||
90 | /* FIXME use a qdev drive property instead of drive_get_next() */ | ||
91 | dinfo = drive_get_next(IF_SD); | ||
92 | blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; | ||
93 | - s->card = sd_init(blk, false); | ||
94 | - if (s->card == NULL) { | ||
95 | - error_setg(errp, "failed to init SD card"); | ||
96 | + carddev = qdev_create(&s->sdbus.qbus, TYPE_SD_CARD); | ||
97 | + qdev_prop_set_drive(carddev, "drive", blk, &err); | ||
98 | + object_property_set_bool(OBJECT(carddev), true, "realized", &err); | ||
99 | + if (err) { | ||
100 | + error_setg(errp, "failed to init SD card: %s", error_get_pretty(err)); | ||
101 | return; | ||
102 | } | ||
103 | s->enabled = blk && blk_is_inserted(blk); | ||
104 | -- | ||
105 | 2.16.1 | ||
106 | |||
107 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | On reset the bus will reset the card, | ||
4 | we can now drop the device_reset() call. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
8 | Message-id: 20180216022933.10945-5-f4bug@amsat.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/sd/ssi-sd.c | 32 +++++++++++++++++++------------- | ||
12 | 1 file changed, 19 insertions(+), 13 deletions(-) | ||
13 | |||
14 | diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/sd/ssi-sd.c | ||
17 | +++ b/hw/sd/ssi-sd.c | ||
18 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
19 | int32_t arglen; | ||
20 | int32_t response_pos; | ||
21 | int32_t stopping; | ||
22 | - SDState *sd; | ||
23 | + SDBus sdbus; | ||
24 | } ssi_sd_state; | ||
25 | |||
26 | #define TYPE_SSI_SD "ssi-sd" | ||
27 | @@ -XXX,XX +XXX,XX @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) | ||
28 | request.arg = (s->cmdarg[0] << 24) | (s->cmdarg[1] << 16) | ||
29 | | (s->cmdarg[2] << 8) | s->cmdarg[3]; | ||
30 | DPRINTF("CMD%d arg 0x%08x\n", s->cmd, request.arg); | ||
31 | - s->arglen = sd_do_command(s->sd, &request, longresp); | ||
32 | + s->arglen = sdbus_do_command(&s->sdbus, &request, longresp); | ||
33 | if (s->arglen <= 0) { | ||
34 | s->arglen = 1; | ||
35 | s->response[0] = 4; | ||
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) | ||
37 | DPRINTF("Response 0x%02x\n", s->response[s->response_pos]); | ||
38 | return s->response[s->response_pos++]; | ||
39 | } | ||
40 | - if (sd_data_ready(s->sd)) { | ||
41 | + if (sdbus_data_ready(&s->sdbus)) { | ||
42 | DPRINTF("Data read\n"); | ||
43 | s->mode = SSI_SD_DATA_START; | ||
44 | } else { | ||
45 | @@ -XXX,XX +XXX,XX @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val) | ||
46 | s->mode = SSI_SD_DATA_READ; | ||
47 | return 0xfe; | ||
48 | case SSI_SD_DATA_READ: | ||
49 | - val = sd_read_data(s->sd); | ||
50 | - if (!sd_data_ready(s->sd)) { | ||
51 | + val = sdbus_read_data(&s->sdbus); | ||
52 | + if (!sdbus_data_ready(&s->sdbus)) { | ||
53 | DPRINTF("Data read end\n"); | ||
54 | s->mode = SSI_SD_CMD; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_ssi_sd = { | ||
57 | static void ssi_sd_realize(SSISlave *d, Error **errp) | ||
58 | { | ||
59 | ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d); | ||
60 | + DeviceState *carddev; | ||
61 | DriveInfo *dinfo; | ||
62 | + Error *err = NULL; | ||
63 | |||
64 | + qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, | ||
65 | + DEVICE(d), "sd-bus"); | ||
66 | + | ||
67 | + /* Create and plug in the sd card */ | ||
68 | /* FIXME use a qdev drive property instead of drive_get_next() */ | ||
69 | dinfo = drive_get_next(IF_SD); | ||
70 | - s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true); | ||
71 | - if (s->sd == NULL) { | ||
72 | - error_setg(errp, "Device initialization failed."); | ||
73 | + carddev = qdev_create(&s->sdbus.qbus, TYPE_SD_CARD); | ||
74 | + if (dinfo) { | ||
75 | + qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err); | ||
76 | + } | ||
77 | + object_property_set_bool(OBJECT(carddev), true, "spi", &err); | ||
78 | + object_property_set_bool(OBJECT(carddev), true, "realized", &err); | ||
79 | + if (err) { | ||
80 | + error_setg(errp, "failed to init SD card: %s", error_get_pretty(err)); | ||
81 | return; | ||
82 | } | ||
83 | } | ||
84 | @@ -XXX,XX +XXX,XX @@ static void ssi_sd_reset(DeviceState *dev) | ||
85 | s->arglen = 0; | ||
86 | s->response_pos = 0; | ||
87 | s->stopping = 0; | ||
88 | - | ||
89 | - /* Since we're still using the legacy SD API the card is not plugged | ||
90 | - * into any bus, and we must reset it manually. | ||
91 | - */ | ||
92 | - device_reset(DEVICE(s->sd)); | ||
93 | } | ||
94 | |||
95 | static void ssi_sd_class_init(ObjectClass *klass, void *data) | ||
96 | -- | ||
97 | 2.16.1 | ||
98 | |||
99 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | place card registers first, this will ease further code movements. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180215220540.6556-2-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/sd/sd.c | 16 +++++++++------- | ||
11 | 1 file changed, 9 insertions(+), 7 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sd.c | ||
16 | +++ b/hw/sd/sd.c | ||
17 | @@ -XXX,XX +XXX,XX @@ enum SDCardStates { | ||
18 | struct SDState { | ||
19 | DeviceState parent_obj; | ||
20 | |||
21 | - uint32_t mode; /* current card mode, one of SDCardModes */ | ||
22 | - int32_t state; /* current card state, one of SDCardStates */ | ||
23 | + /* SD Memory Card Registers */ | ||
24 | uint32_t ocr; | ||
25 | - QEMUTimer *ocr_power_timer; | ||
26 | uint8_t scr[8]; | ||
27 | uint8_t cid[16]; | ||
28 | uint8_t csd[16]; | ||
29 | uint16_t rca; | ||
30 | uint32_t card_status; | ||
31 | uint8_t sd_status[64]; | ||
32 | + | ||
33 | + /* Configurable properties */ | ||
34 | + BlockBackend *blk; | ||
35 | + bool spi; | ||
36 | + | ||
37 | + uint32_t mode; /* current card mode, one of SDCardModes */ | ||
38 | + int32_t state; /* current card state, one of SDCardStates */ | ||
39 | uint32_t vhs; | ||
40 | bool wp_switch; | ||
41 | unsigned long *wp_groups; | ||
42 | @@ -XXX,XX +XXX,XX @@ struct SDState { | ||
43 | uint8_t pwd[16]; | ||
44 | uint32_t pwd_len; | ||
45 | uint8_t function_group[6]; | ||
46 | - | ||
47 | - bool spi; | ||
48 | uint8_t current_cmd; | ||
49 | /* True if we will handle the next command as an ACMD. Note that this does | ||
50 | * *not* track the APP_CMD status bit! | ||
51 | @@ -XXX,XX +XXX,XX @@ struct SDState { | ||
52 | uint8_t data[512]; | ||
53 | qemu_irq readonly_cb; | ||
54 | qemu_irq inserted_cb; | ||
55 | - BlockBackend *blk; | ||
56 | - | ||
57 | + QEMUTimer *ocr_power_timer; | ||
58 | bool enable; | ||
59 | uint8_t dat_lines; | ||
60 | bool cmd_line; | ||
61 | -- | ||
62 | 2.16.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215220540.6556-3-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sd.c | 32 ++++++++++++++++++++++++++------ | ||
9 | hw/sd/trace-events | 6 ++++++ | ||
10 | 2 files changed, 32 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/sd/sd.c | ||
15 | +++ b/hw/sd/sd.c | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #include "qemu/error-report.h" | ||
18 | #include "qemu/timer.h" | ||
19 | #include "qemu/log.h" | ||
20 | +#include "trace.h" | ||
21 | |||
22 | //#define DEBUG_SD 1 | ||
23 | |||
24 | @@ -XXX,XX +XXX,XX @@ struct SDState { | ||
25 | bool cmd_line; | ||
26 | }; | ||
27 | |||
28 | +static const char *sd_state_name(enum SDCardStates state) | ||
29 | +{ | ||
30 | + static const char *state_name[] = { | ||
31 | + [sd_idle_state] = "idle", | ||
32 | + [sd_ready_state] = "ready", | ||
33 | + [sd_identification_state] = "identification", | ||
34 | + [sd_standby_state] = "standby", | ||
35 | + [sd_transfer_state] = "transfer", | ||
36 | + [sd_sendingdata_state] = "sendingdata", | ||
37 | + [sd_receivingdata_state] = "receivingdata", | ||
38 | + [sd_programming_state] = "programming", | ||
39 | + [sd_disconnect_state] = "disconnect", | ||
40 | + }; | ||
41 | + if (state == sd_inactive_state) { | ||
42 | + return "inactive"; | ||
43 | + } | ||
44 | + assert(state <= ARRAY_SIZE(state_name)); | ||
45 | + return state_name[state]; | ||
46 | +} | ||
47 | + | ||
48 | static uint8_t sd_get_dat_lines(SDState *sd) | ||
49 | { | ||
50 | return sd->enable ? sd->dat_lines : 0; | ||
51 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
52 | uint32_t rca = 0x0000; | ||
53 | uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; | ||
54 | |||
55 | + trace_sdcard_normal_command(req.cmd, req.arg, sd_state_name(sd->state)); | ||
56 | + | ||
57 | /* Not interpreting this as an app command */ | ||
58 | sd->card_status &= ~APP_CMD; | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
61 | sd->multi_blk_cnt = 0; | ||
62 | } | ||
63 | |||
64 | - DPRINTF("CMD%d 0x%08x state %d\n", req.cmd, req.arg, sd->state); | ||
65 | switch (req.cmd) { | ||
66 | /* Basic commands (Class 0 and Class 1) */ | ||
67 | case 0: /* CMD0: GO_IDLE_STATE */ | ||
68 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
69 | return sd_r1; | ||
70 | |||
71 | case 56: /* CMD56: GEN_CMD */ | ||
72 | - fprintf(stderr, "SD: GEN_CMD 0x%08x\n", req.arg); | ||
73 | - | ||
74 | switch (sd->state) { | ||
75 | case sd_transfer_state: | ||
76 | sd->data_offset = 0; | ||
77 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
78 | static sd_rsp_type_t sd_app_command(SDState *sd, | ||
79 | SDRequest req) | ||
80 | { | ||
81 | - DPRINTF("ACMD%d 0x%08x\n", req.cmd, req.arg); | ||
82 | + trace_sdcard_app_command(req.cmd, req.arg); | ||
83 | sd->card_status |= APP_CMD; | ||
84 | switch (req.cmd) { | ||
85 | case 6: /* ACMD6: SET_BUS_WIDTH */ | ||
86 | @@ -XXX,XX +XXX,XX @@ send_response: | ||
87 | |||
88 | static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) | ||
89 | { | ||
90 | - DPRINTF("sd_blk_read: addr = 0x%08llx, len = %d\n", | ||
91 | - (unsigned long long) addr, len); | ||
92 | + trace_sdcard_read_block(addr, len); | ||
93 | if (!sd->blk || blk_pread(sd->blk, addr, sd->data, len) < 0) { | ||
94 | fprintf(stderr, "sd_blk_read: read error on host side\n"); | ||
95 | } | ||
96 | @@ -XXX,XX +XXX,XX @@ static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) | ||
97 | |||
98 | static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) | ||
99 | { | ||
100 | + trace_sdcard_write_block(addr, len); | ||
101 | if (!sd->blk || blk_pwrite(sd->blk, addr, sd->data, len, 0) < 0) { | ||
102 | fprintf(stderr, "sd_blk_write: write error on host side\n"); | ||
103 | } | ||
104 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/hw/sd/trace-events | ||
107 | +++ b/hw/sd/trace-events | ||
108 | @@ -XXX,XX +XXX,XX @@ sdhci_read_dataport(uint16_t data_count) "all %u bytes of data have been read fr | ||
109 | sdhci_write_dataport(uint16_t data_count) "write buffer filled with %u bytes of data" | ||
110 | sdhci_capareg(const char *desc, uint16_t val) "%s: %u" | ||
111 | |||
112 | +# hw/sd/sd.c | ||
113 | +sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 0x%08x (state %s)" | ||
114 | +sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x" | ||
115 | +sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
116 | +sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
117 | + | ||
118 | # hw/sd/milkymist-memcard.c | ||
119 | milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
120 | milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
121 | -- | ||
122 | 2.16.1 | ||
123 | |||
124 | diff view generated by jsdifflib |
1 | From: "Emilio G. Cota" <cota@braap.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Fixes the following warning when compiling with gcc 5.4.0 with -O1 | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | optimizations and --enable-debug: | 4 | Message-id: 20180215220540.6556-4-f4bug@amsat.org |
5 | |||
6 | target/arm/translate-a64.c: In function ‘aarch64_tr_translate_insn’: | ||
7 | target/arm/translate-a64.c:2361:8: error: ‘post_index’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | ||
8 | if (!post_index) { | ||
9 | ^ | ||
10 | target/arm/translate-a64.c:2307:10: note: ‘post_index’ was declared here | ||
11 | bool post_index; | ||
12 | ^ | ||
13 | target/arm/translate-a64.c:2386:8: error: ‘writeback’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | ||
14 | if (writeback) { | ||
15 | ^ | ||
16 | target/arm/translate-a64.c:2308:10: note: ‘writeback’ was declared here | ||
17 | bool writeback; | ||
18 | ^ | ||
19 | |||
20 | Note that idx comes from selecting 2 bits, and therefore its value | ||
21 | can be at most 3. | ||
22 | |||
23 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
24 | Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
25 | Message-id: 1510087611-1851-1-git-send-email-cota@braap.org | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 7 | --- |
29 | target/arm/translate-a64.c | 2 ++ | 8 | hw/sd/sd.c | 27 ++++++++++++++++++++++++--- |
30 | 1 file changed, 2 insertions(+) | 9 | hw/sd/trace-events | 1 + |
10 | 2 files changed, 25 insertions(+), 3 deletions(-) | ||
31 | 11 | ||
32 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
33 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/translate-a64.c | 14 | --- a/hw/sd/sd.c |
35 | +++ b/target/arm/translate-a64.c | 15 | +++ b/hw/sd/sd.c |
36 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn, | 16 | @@ -XXX,XX +XXX,XX @@ static const char *sd_state_name(enum SDCardStates state) |
37 | post_index = false; | 17 | return state_name[state]; |
38 | writeback = true; | 18 | } |
19 | |||
20 | +static const char *sd_response_name(sd_rsp_type_t rsp) | ||
21 | +{ | ||
22 | + static const char *response_name[] = { | ||
23 | + [sd_r0] = "RESP#0 (no response)", | ||
24 | + [sd_r1] = "RESP#1 (normal cmd)", | ||
25 | + [sd_r2_i] = "RESP#2 (CID reg)", | ||
26 | + [sd_r2_s] = "RESP#2 (CSD reg)", | ||
27 | + [sd_r3] = "RESP#3 (OCR reg)", | ||
28 | + [sd_r6] = "RESP#6 (RCA)", | ||
29 | + [sd_r7] = "RESP#7 (operating voltage)", | ||
30 | + }; | ||
31 | + if (rsp == sd_illegal) { | ||
32 | + return "ILLEGAL RESP"; | ||
33 | + } | ||
34 | + if (rsp == sd_r1b) { | ||
35 | + rsp = sd_r1; | ||
36 | + } | ||
37 | + assert(rsp <= ARRAY_SIZE(response_name)); | ||
38 | + return response_name[rsp]; | ||
39 | +} | ||
40 | + | ||
41 | static uint8_t sd_get_dat_lines(SDState *sd) | ||
42 | { | ||
43 | return sd->enable ? sd->dat_lines : 0; | ||
44 | @@ -XXX,XX +XXX,XX @@ send_response: | ||
45 | |||
46 | case sd_r0: | ||
47 | case sd_illegal: | ||
48 | - default: | ||
49 | rsplen = 0; | ||
39 | break; | 50 | break; |
40 | + default: | 51 | + default: |
41 | + g_assert_not_reached(); | 52 | + g_assert_not_reached(); |
42 | } | 53 | } |
43 | 54 | + trace_sdcard_response(sd_response_name(rtype), rsplen); | |
44 | if (rn == 31) { | 55 | |
56 | if (rtype != sd_illegal) { | ||
57 | /* Clear the "clear on valid command" status bits now we've | ||
58 | @@ -XXX,XX +XXX,XX @@ send_response: | ||
59 | DPRINTF(" %02x", response[i]); | ||
60 | } | ||
61 | DPRINTF(" state %d\n", sd->state); | ||
62 | - } else { | ||
63 | - DPRINTF("No response %d\n", sd->state); | ||
64 | } | ||
65 | #endif | ||
66 | |||
67 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/hw/sd/trace-events | ||
70 | +++ b/hw/sd/trace-events | ||
71 | @@ -XXX,XX +XXX,XX @@ sdhci_capareg(const char *desc, uint16_t val) "%s: %u" | ||
72 | # hw/sd/sd.c | ||
73 | sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 0x%08x (state %s)" | ||
74 | sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x" | ||
75 | +sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" | ||
76 | sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
77 | sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
78 | |||
45 | -- | 79 | -- |
46 | 2.7.4 | 80 | 2.16.1 |
47 | 81 | ||
48 | 82 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215220540.6556-5-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sd.c | 16 +--------------- | ||
9 | 1 file changed, 1 insertion(+), 15 deletions(-) | ||
10 | |||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/sd/sd.c | ||
14 | +++ b/hw/sd/sd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | |||
17 | //#define DEBUG_SD 1 | ||
18 | |||
19 | -#ifdef DEBUG_SD | ||
20 | -#define DPRINTF(fmt, ...) \ | ||
21 | -do { fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); } while (0) | ||
22 | -#else | ||
23 | -#define DPRINTF(fmt, ...) do {} while(0) | ||
24 | -#endif | ||
25 | - | ||
26 | #define ACMD41_ENQUIRY_MASK 0x00ffffff | ||
27 | #define OCR_POWER_UP 0x80000000 | ||
28 | #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | ||
29 | @@ -XXX,XX +XXX,XX @@ send_response: | ||
30 | } | ||
31 | |||
32 | #ifdef DEBUG_SD | ||
33 | - if (rsplen) { | ||
34 | - int i; | ||
35 | - DPRINTF("Response:"); | ||
36 | - for (i = 0; i < rsplen; i++) { | ||
37 | - DPRINTF(" %02x", response[i]); | ||
38 | - } | ||
39 | - DPRINTF(" state %d\n", sd->state); | ||
40 | - } | ||
41 | + qemu_hexdump((const char *)response, stderr, "Response", rsplen); | ||
42 | #endif | ||
43 | |||
44 | return rsplen; | ||
45 | -- | ||
46 | 2.16.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Acked-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215220540.6556-6-f4bug@amsat.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/sd/sd.c | 32 ++++++++++++++++++++++++++------ | ||
10 | hw/sd/trace-events | 13 +++++++++++++ | ||
11 | 2 files changed, 39 insertions(+), 6 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sd.c | ||
16 | +++ b/hw/sd/sd.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static bool sd_get_cmd_line(SDState *sd) | ||
18 | |||
19 | static void sd_set_voltage(SDState *sd, uint16_t millivolts) | ||
20 | { | ||
21 | + trace_sdcard_set_voltage(millivolts); | ||
22 | + | ||
23 | switch (millivolts) { | ||
24 | case 3001 ... 3600: /* SD_VOLTAGE_3_3V */ | ||
25 | case 2001 ... 3000: /* SD_VOLTAGE_3_0V */ | ||
26 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | ||
27 | { | ||
28 | SDState *sd = opaque; | ||
29 | |||
30 | + trace_sdcard_powerup(); | ||
31 | /* Set powered up bit in OCR */ | ||
32 | assert(!(sd->ocr & OCR_POWER_UP)); | ||
33 | sd->ocr |= OCR_POWER_UP; | ||
34 | @@ -XXX,XX +XXX,XX @@ static void sd_reset(DeviceState *dev) | ||
35 | uint64_t size; | ||
36 | uint64_t sect; | ||
37 | |||
38 | + trace_sdcard_reset(); | ||
39 | if (sd->blk) { | ||
40 | blk_get_geometry(sd->blk, §); | ||
41 | } else { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void sd_cardchange(void *opaque, bool load, Error **errp) | ||
43 | bool readonly = sd_get_readonly(sd); | ||
44 | |||
45 | if (inserted) { | ||
46 | + trace_sdcard_inserted(readonly); | ||
47 | sd_reset(dev); | ||
48 | + } else { | ||
49 | + trace_sdcard_ejected(); | ||
50 | } | ||
51 | |||
52 | /* The IRQ notification is for legacy non-QOM SD controller devices; | ||
53 | @@ -XXX,XX +XXX,XX @@ static void sd_erase(SDState *sd) | ||
54 | uint64_t erase_start = sd->erase_start; | ||
55 | uint64_t erase_end = sd->erase_end; | ||
56 | |||
57 | + trace_sdcard_erase(); | ||
58 | if (!sd->erase_start || !sd->erase_end) { | ||
59 | sd->card_status |= ERASE_SEQ_ERROR; | ||
60 | return; | ||
61 | @@ -XXX,XX +XXX,XX @@ static void sd_lock_command(SDState *sd) | ||
62 | else | ||
63 | pwd_len = 0; | ||
64 | |||
65 | + if (lock) { | ||
66 | + trace_sdcard_lock(); | ||
67 | + } else { | ||
68 | + trace_sdcard_unlock(); | ||
69 | + } | ||
70 | if (erase) { | ||
71 | if (!(sd->card_status & CARD_IS_LOCKED) || sd->blk_len > 1 || | ||
72 | set_pwd || clr_pwd || lock || sd->wp_switch || | ||
73 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
74 | case 16: /* CMD16: SET_BLOCKLEN */ | ||
75 | switch (sd->state) { | ||
76 | case sd_transfer_state: | ||
77 | - if (req.arg > (1 << HWBLOCK_SHIFT)) | ||
78 | + if (req.arg > (1 << HWBLOCK_SHIFT)) { | ||
79 | sd->card_status |= BLOCK_LEN_ERROR; | ||
80 | - else | ||
81 | + } else { | ||
82 | + trace_sdcard_set_blocklen(req.arg); | ||
83 | sd->blk_len = req.arg; | ||
84 | + } | ||
85 | |||
86 | return sd_r1; | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
89 | if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | ||
90 | timer_del(sd->ocr_power_timer); | ||
91 | sd_ocr_powerup(sd); | ||
92 | - } else if (!timer_pending(sd->ocr_power_timer)) { | ||
93 | - timer_mod_ns(sd->ocr_power_timer, | ||
94 | - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
95 | - + OCR_POWER_DELAY_NS)); | ||
96 | + } else { | ||
97 | + trace_sdcard_inquiry_cmd41(); | ||
98 | + if (!timer_pending(sd->ocr_power_timer)) { | ||
99 | + timer_mod_ns(sd->ocr_power_timer, | ||
100 | + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
101 | + + OCR_POWER_DELAY_NS)); | ||
102 | + } | ||
103 | } | ||
104 | } | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ void sd_write_data(SDState *sd, uint8_t value) | ||
107 | if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) | ||
108 | return; | ||
109 | |||
110 | + trace_sdcard_write_data(sd->current_cmd, value); | ||
111 | switch (sd->current_cmd) { | ||
112 | case 24: /* CMD24: WRITE_SINGLE_BLOCK */ | ||
113 | sd->data[sd->data_offset ++] = value; | ||
114 | @@ -XXX,XX +XXX,XX @@ uint8_t sd_read_data(SDState *sd) | ||
115 | |||
116 | io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; | ||
117 | |||
118 | + trace_sdcard_read_data(sd->current_cmd, io_len); | ||
119 | switch (sd->current_cmd) { | ||
120 | case 6: /* CMD6: SWITCH_FUNCTION */ | ||
121 | ret = sd->data[sd->data_offset ++]; | ||
122 | diff --git a/hw/sd/trace-events b/hw/sd/trace-events | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/sd/trace-events | ||
125 | +++ b/hw/sd/trace-events | ||
126 | @@ -XXX,XX +XXX,XX @@ sdhci_capareg(const char *desc, uint16_t val) "%s: %u" | ||
127 | sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 0x%08x (state %s)" | ||
128 | sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x" | ||
129 | sdcard_response(const char *rspdesc, int rsplen) "%s (sz:%d)" | ||
130 | +sdcard_powerup(void) "" | ||
131 | +sdcard_inquiry_cmd41(void) "" | ||
132 | +sdcard_set_enable(bool current_state, bool new_state) "%u -> %u" | ||
133 | +sdcard_reset(void) "" | ||
134 | +sdcard_set_blocklen(uint16_t length) "0x%04x" | ||
135 | +sdcard_inserted(bool readonly) "read_only: %u" | ||
136 | +sdcard_ejected(void) "" | ||
137 | +sdcard_erase(void) "" | ||
138 | +sdcard_lock(void) "" | ||
139 | +sdcard_unlock(void) "" | ||
140 | sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
141 | sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" | ||
142 | +sdcard_write_data(uint8_t cmd, uint8_t value) "CMD%02d value 0x%02x" | ||
143 | +sdcard_read_data(uint8_t cmd, int length) "CMD%02d len %d" | ||
144 | +sdcard_set_voltage(uint16_t millivolts) "%u mV" | ||
145 | |||
146 | # hw/sd/milkymist-memcard.c | ||
147 | milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" | ||
148 | -- | ||
149 | 2.16.1 | ||
150 | |||
151 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Allow the -smp command line option to control the number of CPUs we | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | create. | 4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> |
5 | 5 | Message-id: 20180215220540.6556-8-f4bug@amsat.org | |
6 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
8 | Reviewed-by: Emilio G. Cota <cota@braap.org> | ||
9 | Tested-by: Emilio G. Cota <cota@braap.org> | ||
10 | Message-id: 1510343626-25861-3-git-send-email-cota@braap.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | hw/arm/xlnx-zcu102.c | 3 ++- | 8 | hw/sd/sdmmc-internal.h | 15 +++++++++++++++ |
14 | hw/arm/xlnx-zynqmp.c | 26 ++++++++++++++++---------- | 9 | hw/sd/sd.c | 22 ++++++++++++++++------ |
15 | 2 files changed, 18 insertions(+), 11 deletions(-) | 10 | 2 files changed, 31 insertions(+), 6 deletions(-) |
11 | create mode 100644 hw/sd/sdmmc-internal.h | ||
16 | 12 | ||
17 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | 13 | diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h |
14 | new file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- /dev/null | ||
17 | +++ b/hw/sd/sdmmc-internal.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | +/* | ||
20 | + * SD/MMC cards common | ||
21 | + * | ||
22 | + * Copyright (c) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
23 | + * | ||
24 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
25 | + * See the COPYING file in the top-level directory. | ||
26 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
27 | + */ | ||
28 | +#ifndef SD_INTERNAL_H | ||
29 | +#define SD_INTERNAL_H | ||
30 | + | ||
31 | +#define SDMMC_CMD_MAX 64 | ||
32 | + | ||
33 | +#endif | ||
34 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/xlnx-zcu102.c | 36 | --- a/hw/sd/sd.c |
20 | +++ b/hw/arm/xlnx-zcu102.c | 37 | +++ b/hw/sd/sd.c |
21 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data) | 38 | @@ -XXX,XX +XXX,XX @@ |
22 | { | 39 | #include "qemu/error-report.h" |
23 | MachineClass *mc = MACHINE_CLASS(oc); | 40 | #include "qemu/timer.h" |
24 | 41 | #include "qemu/log.h" | |
25 | - mc->desc = "Xilinx ZynqMP ZCU102 board"; | 42 | +#include "sdmmc-internal.h" |
26 | + mc->desc = "Xilinx ZynqMP ZCU102 board with 4xA53s and 2xR5s based on " \ | 43 | #include "trace.h" |
27 | + "the value of smp"; | 44 | |
28 | mc->init = xlnx_zcu102_init; | 45 | //#define DEBUG_SD 1 |
29 | mc->block_default_type = IF_IDE; | 46 | @@ -XXX,XX +XXX,XX @@ static void sd_set_mode(SDState *sd) |
30 | mc->units_per_default_bus = 1; | ||
31 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/xlnx-zynqmp.c | ||
34 | +++ b/hw/arm/xlnx-zynqmp.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cpu, | ||
36 | { | ||
37 | Error *err = NULL; | ||
38 | int i; | ||
39 | + int num_rpus = MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_NUM_RPU_CPUS); | ||
40 | |||
41 | - for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) { | ||
42 | + for (i = 0; i < num_rpus; i++) { | ||
43 | char *name; | ||
44 | |||
45 | object_initialize(&s->rpu_cpu[i], sizeof(s->rpu_cpu[i]), | ||
46 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_init(Object *obj) | ||
47 | { | ||
48 | XlnxZynqMPState *s = XLNX_ZYNQMP(obj); | ||
49 | int i; | ||
50 | + int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); | ||
51 | |||
52 | - for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) { | ||
53 | + for (i = 0; i < num_apus; i++) { | ||
54 | object_initialize(&s->apu_cpu[i], sizeof(s->apu_cpu[i]), | ||
55 | "cortex-a53-" TYPE_ARM_CPU); | ||
56 | object_property_add_child(obj, "apu-cpu[*]", OBJECT(&s->apu_cpu[i]), | ||
57 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
58 | MemoryRegion *system_memory = get_system_memory(); | ||
59 | uint8_t i; | ||
60 | uint64_t ram_size; | ||
61 | + int num_apus = MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); | ||
62 | const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]"; | ||
63 | ram_addr_t ddr_low_size, ddr_high_size; | ||
64 | qemu_irq gic_spi[GIC_NUM_SPI_INTR]; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
66 | |||
67 | qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32); | ||
68 | qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2); | ||
69 | - qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS); | ||
70 | + qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", num_apus); | ||
71 | |||
72 | /* Realize APUs before realizing the GIC. KVM requires this. */ | ||
73 | - for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) { | ||
74 | + for (i = 0; i < num_apus; i++) { | ||
75 | char *name; | ||
76 | |||
77 | object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC, | ||
78 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
79 | } | ||
80 | } | 47 | } |
81 | 48 | } | |
82 | - for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) { | 49 | |
83 | + for (i = 0; i < num_apus; i++) { | 50 | -static const sd_cmd_type_t sd_cmd_type[64] = { |
84 | qemu_irq irq; | 51 | +static const sd_cmd_type_t sd_cmd_type[SDMMC_CMD_MAX] = { |
85 | 52 | sd_bc, sd_none, sd_bcr, sd_bcr, sd_none, sd_none, sd_none, sd_ac, | |
86 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i, | 53 | sd_bcr, sd_ac, sd_ac, sd_adtc, sd_ac, sd_ac, sd_none, sd_ac, |
87 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 54 | + /* 16 */ |
55 | sd_ac, sd_adtc, sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, | ||
56 | sd_adtc, sd_adtc, sd_adtc, sd_adtc, sd_ac, sd_ac, sd_adtc, sd_none, | ||
57 | + /* 32 */ | ||
58 | sd_ac, sd_ac, sd_none, sd_none, sd_none, sd_none, sd_ac, sd_none, | ||
59 | sd_none, sd_none, sd_bc, sd_none, sd_none, sd_none, sd_none, sd_none, | ||
60 | + /* 48 */ | ||
61 | sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_ac, | ||
62 | sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, | ||
63 | }; | ||
64 | |||
65 | -static const int sd_cmd_class[64] = { | ||
66 | +static const int sd_cmd_class[SDMMC_CMD_MAX] = { | ||
67 | 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, | ||
68 | 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, | ||
69 | 5, 5, 10, 10, 10, 10, 5, 9, 9, 9, 7, 7, 7, 7, 7, 7, | ||
70 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
71 | /* Not interpreting this as an app command */ | ||
72 | sd->card_status &= ~APP_CMD; | ||
73 | |||
74 | - if (sd_cmd_type[req.cmd & 0x3F] == sd_ac | ||
75 | - || sd_cmd_type[req.cmd & 0x3F] == sd_adtc) { | ||
76 | + if (sd_cmd_type[req.cmd] == sd_ac | ||
77 | + || sd_cmd_type[req.cmd] == sd_adtc) { | ||
78 | rca = req.arg >> 16; | ||
88 | } | 79 | } |
89 | 80 | ||
90 | if (s->has_rpu) { | 81 | @@ -XXX,XX +XXX,XX @@ static int cmd_valid_while_locked(SDState *sd, SDRequest *req) |
91 | - xlnx_zynqmp_create_rpu(s, boot_cpu, &err); | 82 | if (req->cmd == 16 || req->cmd == 55) { |
92 | - if (err) { | 83 | return 1; |
93 | - error_propagate(errp, err); | 84 | } |
94 | - return; | 85 | - return sd_cmd_class[req->cmd & 0x3F] == 0 |
95 | - } | 86 | - || sd_cmd_class[req->cmd & 0x3F] == 7; |
96 | + info_report("The 'has_rpu' property is no longer required, to use the " | 87 | + return sd_cmd_class[req->cmd] == 0 |
97 | + "RPUs just use -smp 6."); | 88 | + || sd_cmd_class[req->cmd] == 7; |
89 | } | ||
90 | |||
91 | int sd_do_command(SDState *sd, SDRequest *req, | ||
92 | @@ -XXX,XX +XXX,XX @@ int sd_do_command(SDState *sd, SDRequest *req, | ||
93 | goto send_response; | ||
94 | } | ||
95 | |||
96 | + if (req->cmd >= SDMMC_CMD_MAX) { | ||
97 | + qemu_log_mask(LOG_GUEST_ERROR, "SD: incorrect command 0x%02x\n", | ||
98 | + req->cmd); | ||
99 | + req->cmd &= 0x3f; | ||
98 | + } | 100 | + } |
99 | + | 101 | + |
100 | + xlnx_zynqmp_create_rpu(s, boot_cpu, &err); | 102 | if (sd->card_status & CARD_IS_LOCKED) { |
101 | + if (err) { | 103 | if (!cmd_valid_while_locked(sd, req)) { |
102 | + error_propagate(errp, err); | 104 | sd->card_status |= ILLEGAL_COMMAND; |
103 | + return; | ||
104 | } | ||
105 | |||
106 | if (!s->boot_cpu_ptr) { | ||
107 | -- | 105 | -- |
108 | 2.7.4 | 106 | 2.16.1 |
109 | 107 | ||
110 | 108 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | code is now easier to read. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180215220540.6556-11-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/sd/sd.c | 3 ++- | ||
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sd.c | ||
16 | +++ b/hw/sd/sd.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #include "hw/sd/sd.h" | ||
19 | #include "qapi/error.h" | ||
20 | #include "qemu/bitmap.h" | ||
21 | +#include "qemu/cutils.h" | ||
22 | #include "hw/qdev-properties.h" | ||
23 | #include "qemu/error-report.h" | ||
24 | #include "qemu/timer.h" | ||
25 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | ||
26 | uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1; | ||
27 | uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1; | ||
28 | |||
29 | - if (size <= 0x40000000) { /* Standard Capacity SD */ | ||
30 | + if (size <= 1 * G_BYTE) { /* Standard Capacity SD */ | ||
31 | sd->csd[0] = 0x00; /* CSD structure */ | ||
32 | sd->csd[1] = 0x26; /* Data read access-time-1 */ | ||
33 | sd->csd[2] = 0x00; /* Data read access-time-2 */ | ||
34 | -- | ||
35 | 2.16.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215220540.6556-12-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/sd/sd.h | 1 - | ||
9 | hw/sd/sd.c | 21 +++++++++++++-------- | ||
10 | 2 files changed, 13 insertions(+), 9 deletions(-) | ||
11 | |||
12 | diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/sd/sd.h | ||
15 | +++ b/include/hw/sd/sd.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #define READY_FOR_DATA (1 << 8) | ||
18 | #define APP_CMD (1 << 5) | ||
19 | #define AKE_SEQ_ERROR (1 << 3) | ||
20 | -#define OCR_CCS_BITN 30 | ||
21 | |||
22 | typedef enum { | ||
23 | SD_VOLTAGE_0_4V = 400, /* currently not supported */ | ||
24 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/sd/sd.c | ||
27 | +++ b/hw/sd/sd.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #include "qemu/osdep.h" | ||
30 | #include "hw/qdev.h" | ||
31 | #include "hw/hw.h" | ||
32 | +#include "hw/registerfields.h" | ||
33 | #include "sysemu/block-backend.h" | ||
34 | #include "hw/sd/sd.h" | ||
35 | #include "qapi/error.h" | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | //#define DEBUG_SD 1 | ||
38 | |||
39 | #define ACMD41_ENQUIRY_MASK 0x00ffffff | ||
40 | -#define OCR_POWER_UP 0x80000000 | ||
41 | -#define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | ||
42 | |||
43 | typedef enum { | ||
44 | sd_r0 = 0, /* no response */ | ||
45 | @@ -XXX,XX +XXX,XX @@ static uint16_t sd_crc16(void *message, size_t width) | ||
46 | return shift_reg; | ||
47 | } | ||
48 | |||
49 | +#define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | ||
50 | + | ||
51 | +FIELD(OCR, CARD_CAPACITY, 30, 1) /* 0:SDSC, 1:SDHC/SDXC */ | ||
52 | +FIELD(OCR, CARD_POWER_UP, 31, 1) | ||
53 | + | ||
54 | static void sd_set_ocr(SDState *sd) | ||
55 | { | ||
56 | /* All voltages OK, Standard Capacity SD Memory Card, not yet powered up */ | ||
57 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | ||
58 | SDState *sd = opaque; | ||
59 | |||
60 | trace_sdcard_powerup(); | ||
61 | - /* Set powered up bit in OCR */ | ||
62 | - assert(!(sd->ocr & OCR_POWER_UP)); | ||
63 | - sd->ocr |= OCR_POWER_UP; | ||
64 | + assert(!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)); | ||
65 | + | ||
66 | + /* card power-up OK */ | ||
67 | + sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1); | ||
68 | } | ||
69 | |||
70 | static void sd_set_scr(SDState *sd) | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool sd_ocr_vmstate_needed(void *opaque) | ||
72 | SDState *sd = opaque; | ||
73 | |||
74 | /* Include the OCR state (and timer) if it is not yet powered up */ | ||
75 | - return !(sd->ocr & OCR_POWER_UP); | ||
76 | + return !FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP); | ||
77 | } | ||
78 | |||
79 | static const VMStateDescription sd_ocr_vmstate = { | ||
80 | @@ -XXX,XX +XXX,XX @@ static void sd_erase(SDState *sd) | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | - if (extract32(sd->ocr, OCR_CCS_BITN, 1)) { | ||
85 | + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { | ||
86 | /* High capacity memory card: erase units are 512 byte blocks */ | ||
87 | erase_start *= 512; | ||
88 | erase_end *= 512; | ||
89 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
90 | * UEFI, which sends an initial enquiry ACMD41, but | ||
91 | * assumes that the card is in ready state as soon as it | ||
92 | * sees the power up bit set. */ | ||
93 | - if (!(sd->ocr & OCR_POWER_UP)) { | ||
94 | + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { | ||
95 | if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | ||
96 | timer_del(sd->ocr_power_timer); | ||
97 | sd_ocr_powerup(sd); | ||
98 | -- | ||
99 | 2.16.1 | ||
100 | |||
101 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The EP108 was an early access development board that is no longer used. | 3 | Don't set the high capacity bit by default as it will be set if required |
4 | Add an info message to convert any users to the ZCU102 instead. On QEMU | 4 | in the sd_set_csd() function. |
5 | they are both identical. | ||
6 | 5 | ||
7 | This patch also updated the qemu-doc.texi file to indicate that the | 6 | [based on a patch from Alistair Francis <alistair.francis@xilinx.com> |
8 | EP108 has been deprecated. | 7 | and Peter Ogden <ogden@xilinx.com> from qemu/xilinx tag xilinx-v2015.4] |
9 | 8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
10 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 9 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> |
11 | Reviewed-by: Emilio G. Cota <cota@braap.org> | 10 | Message-id: 20180215221325.7611-2-f4bug@amsat.org |
12 | Message-id: 1510343626-25861-4-git-send-email-cota@braap.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 12 | --- |
15 | hw/arm/xlnx-zcu102.c | 3 +++ | 13 | hw/sd/sd.c | 5 ++++- |
16 | qemu-doc.texi | 7 +++++++ | 14 | 1 file changed, 4 insertions(+), 1 deletion(-) |
17 | 2 files changed, 10 insertions(+) | ||
18 | 15 | ||
19 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | 16 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/xlnx-zcu102.c | 18 | --- a/hw/sd/sd.c |
22 | +++ b/hw/arm/xlnx-zcu102.c | 19 | +++ b/hw/sd/sd.c |
23 | @@ -XXX,XX +XXX,XX @@ static void xlnx_ep108_init(MachineState *machine) | 20 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) |
24 | { | 21 | |
25 | XlnxZCU102 *s = EP108_MACHINE(machine); | 22 | /* card power-up OK */ |
26 | 23 | sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1); | |
27 | + info_report("The Xilinx EP108 machine is deprecated, please use the " | ||
28 | + "ZCU102 machine instead. It has the same features supported."); | ||
29 | + | 24 | + |
30 | xlnx_zynqmp_init(s, machine); | 25 | + if (sd->size > 1 * G_BYTE) { |
26 | + sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1); | ||
27 | + } | ||
31 | } | 28 | } |
32 | 29 | ||
33 | diff --git a/qemu-doc.texi b/qemu-doc.texi | 30 | static void sd_set_scr(SDState *sd) |
34 | index XXXXXXX..XXXXXXX 100644 | 31 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) |
35 | --- a/qemu-doc.texi | 32 | sd->csd[13] = 0x40; |
36 | +++ b/qemu-doc.texi | 33 | sd->csd[14] = 0x00; |
37 | @@ -XXX,XX +XXX,XX @@ or ``ivshmem-doorbell`` device types. | 34 | sd->csd[15] = 0x00; |
38 | The ``spapr-pci-vfio-host-bridge'' device type is replaced by | 35 | - sd->ocr |= 1 << 30; /* High Capacity SD Memory Card */ |
39 | the ``spapr-pci-host-bridge'' device type. | 36 | } |
40 | 37 | } | |
41 | +@section System emulator machines | ||
42 | + | ||
43 | +@subsection Xilinx EP108 (since 2.11.0) | ||
44 | + | ||
45 | +The ``xlnx-ep108'' machine has been replaced by the ``xlnx-zcu102'' machine. | ||
46 | +The ``xlnx-zcu102'' machine has the same features and capabilites in QEMU. | ||
47 | + | ||
48 | @node License | ||
49 | @appendix License | ||
50 | 38 | ||
51 | -- | 39 | -- |
52 | 2.7.4 | 40 | 2.16.1 |
53 | 41 | ||
54 | 42 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215221325.7611-3-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sd.c | 3 +-- | ||
9 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/sd/sd.c | ||
14 | +++ b/hw/sd/sd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | ||
16 | sd->csd[13] = 0x20 | /* Max. write data block length */ | ||
17 | ((HWBLOCK_SHIFT << 6) & 0xc0); | ||
18 | sd->csd[14] = 0x00; /* File format group */ | ||
19 | - sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; | ||
20 | } else { /* SDHC */ | ||
21 | size /= 512 * 1024; | ||
22 | size -= 1; | ||
23 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | ||
24 | sd->csd[12] = 0x0a; | ||
25 | sd->csd[13] = 0x40; | ||
26 | sd->csd[14] = 0x00; | ||
27 | - sd->csd[15] = 0x00; | ||
28 | } | ||
29 | + sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; | ||
30 | } | ||
31 | |||
32 | static void sd_set_rca(SDState *sd) | ||
33 | -- | ||
34 | 2.16.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | To comply with Spec v1.10 (and 2.00, 3.01): | ||
4 | |||
5 | . TRAN_SPEED | ||
6 | |||
7 | for current SD Memory Cards that field must be always 0_0110_010b (032h) which is | ||
8 | equal to 25MHz - the mandatory maximum operating frequency of SD Memory Card. | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
12 | Message-id: 20180215221325.7611-4-f4bug@amsat.org | ||
13 | [PMM: fixed comment indent] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/sd/sd.c | 2 +- | ||
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/sd/sd.c | ||
22 | +++ b/hw/sd/sd.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void sd_set_csd(SDState *sd, uint64_t size) | ||
24 | sd->csd[0] = 0x00; /* CSD structure */ | ||
25 | sd->csd[1] = 0x26; /* Data read access-time-1 */ | ||
26 | sd->csd[2] = 0x00; /* Data read access-time-2 */ | ||
27 | - sd->csd[3] = 0x5a; /* Max. data transfer rate */ | ||
28 | + sd->csd[3] = 0x32; /* Max. data transfer rate: 25 MHz */ | ||
29 | sd->csd[4] = 0x5f; /* Card Command Classes */ | ||
30 | sd->csd[5] = 0x50 | /* Max. read data block length */ | ||
31 | HWBLOCK_SHIFT; | ||
32 | -- | ||
33 | 2.16.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215221325.7611-5-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sd.c | 9 ++++++--- | ||
9 | 1 file changed, 6 insertions(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/sd/sd.c | ||
14 | +++ b/hw/sd/sd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque) | ||
16 | |||
17 | static void sd_set_scr(SDState *sd) | ||
18 | { | ||
19 | - sd->scr[0] = 0x00; /* SCR Structure */ | ||
20 | - sd->scr[1] = 0x2f; /* SD Security Support */ | ||
21 | - sd->scr[2] = 0x00; | ||
22 | + sd->scr[0] = (0 << 4) /* SCR version 1.0 */ | ||
23 | + | 0; /* Spec Versions 1.0 and 1.01 */ | ||
24 | + sd->scr[1] = (2 << 4) /* SDSC Card (Security Version 1.01) */ | ||
25 | + | 0b0101; /* 1-bit or 4-bit width bus modes */ | ||
26 | + sd->scr[2] = 0x00; /* Extended Security is not supported. */ | ||
27 | sd->scr[3] = 0x00; | ||
28 | + /* reserved for manufacturer usage */ | ||
29 | sd->scr[4] = 0x00; | ||
30 | sd->scr[5] = 0x00; | ||
31 | sd->scr[6] = 0x00; | ||
32 | -- | ||
33 | 2.16.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | This device does not model MMCA Specification previous to v4.2 | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180215221325.7611-6-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/sd/sd.c | 33 --------------------------------- | ||
11 | 1 file changed, 33 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sd.c | ||
16 | +++ b/hw/sd/sd.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
18 | } | ||
19 | break; | ||
20 | |||
21 | - case 11: /* CMD11: READ_DAT_UNTIL_STOP */ | ||
22 | - if (sd->spi) | ||
23 | - goto bad_cmd; | ||
24 | - switch (sd->state) { | ||
25 | - case sd_transfer_state: | ||
26 | - sd->state = sd_sendingdata_state; | ||
27 | - sd->data_start = req.arg; | ||
28 | - sd->data_offset = 0; | ||
29 | - | ||
30 | - if (sd->data_start + sd->blk_len > sd->size) | ||
31 | - sd->card_status |= ADDRESS_ERROR; | ||
32 | - return sd_r0; | ||
33 | - | ||
34 | - default: | ||
35 | - break; | ||
36 | - } | ||
37 | - break; | ||
38 | - | ||
39 | case 12: /* CMD12: STOP_TRANSMISSION */ | ||
40 | switch (sd->state) { | ||
41 | case sd_sendingdata_state: | ||
42 | @@ -XXX,XX +XXX,XX @@ uint8_t sd_read_data(SDState *sd) | ||
43 | sd->state = sd_transfer_state; | ||
44 | break; | ||
45 | |||
46 | - case 11: /* CMD11: READ_DAT_UNTIL_STOP */ | ||
47 | - if (sd->data_offset == 0) | ||
48 | - BLK_READ_BLOCK(sd->data_start, io_len); | ||
49 | - ret = sd->data[sd->data_offset ++]; | ||
50 | - | ||
51 | - if (sd->data_offset >= io_len) { | ||
52 | - sd->data_start += io_len; | ||
53 | - sd->data_offset = 0; | ||
54 | - if (sd->data_start + io_len > sd->size) { | ||
55 | - sd->card_status |= ADDRESS_ERROR; | ||
56 | - break; | ||
57 | - } | ||
58 | - } | ||
59 | - break; | ||
60 | - | ||
61 | case 13: /* ACMD13: SD_STATUS */ | ||
62 | ret = sd->sd_status[sd->data_offset ++]; | ||
63 | |||
64 | -- | ||
65 | 2.16.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | We are still seeing signals during translation time when we walk over | 3 | the code is easier to review/refactor. |
4 | a page protection boundary. This expands the check to ensure the host | ||
5 | PC is inside the code generation buffer. The original suggestion was | ||
6 | to check versus tcg_ctx.code_gen_ptr but as we now segment the | ||
7 | translation buffer we have to settle for just a general check for | ||
8 | being inside. | ||
9 | 4 | ||
10 | I've also fixed up the declaration to make it clear it can deal with | 5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | invalid addresses. A later patch will fix up the call sites. | 6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> |
12 | 7 | Message-id: 20180215221325.7611-7-f4bug@amsat.org | |
13 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Laurent Vivier <laurent@vivier.eu> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20171108153245.20740-2-alex.bennee@linaro.org | ||
18 | Suggested-by: Paolo Bonzini <pbonzini@redhat.com> | ||
19 | Cc: Richard Henderson <rth@twiddle.net> | ||
20 | Tested-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 10 | --- |
23 | include/exec/exec-all.h | 11 ++++++++++ | 11 | hw/sd/sd.c | 38 +++++++++----------------------------- |
24 | accel/tcg/translate-all.c | 52 ++++++++++++++++++++++++++--------------------- | 12 | 1 file changed, 9 insertions(+), 29 deletions(-) |
25 | 2 files changed, 40 insertions(+), 23 deletions(-) | ||
26 | 13 | ||
27 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 14 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
28 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/include/exec/exec-all.h | 16 | --- a/hw/sd/sd.c |
30 | +++ b/include/exec/exec-all.h | 17 | +++ b/hw/sd/sd.c |
31 | @@ -XXX,XX +XXX,XX @@ void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, | 18 | @@ -XXX,XX +XXX,XX @@ static int sd_req_crc_validate(SDRequest *req) |
32 | target_ulong *data); | 19 | { |
33 | 20 | uint8_t buffer[5]; | |
34 | void cpu_gen_init(void); | 21 | buffer[0] = 0x40 | req->cmd; |
22 | - buffer[1] = (req->arg >> 24) & 0xff; | ||
23 | - buffer[2] = (req->arg >> 16) & 0xff; | ||
24 | - buffer[3] = (req->arg >> 8) & 0xff; | ||
25 | - buffer[4] = (req->arg >> 0) & 0xff; | ||
26 | + stl_be_p(&buffer[1], req->arg); | ||
27 | return 0; | ||
28 | return sd_crc7(buffer, 5) != req->crc; /* TODO */ | ||
29 | } | ||
30 | |||
31 | static void sd_response_r1_make(SDState *sd, uint8_t *response) | ||
32 | { | ||
33 | - uint32_t status = sd->card_status; | ||
34 | + stl_be_p(response, sd->card_status); | ||
35 | + | 35 | + |
36 | +/** | 36 | /* Clear the "clear on read" status bits */ |
37 | + * cpu_restore_state: | 37 | sd->card_status &= ~CARD_STATUS_C; |
38 | + * @cpu: the vCPU state is to be restore to | 38 | - |
39 | + * @searched_pc: the host PC the fault occurred at | 39 | - response[0] = (status >> 24) & 0xff; |
40 | + * @return: true if state was restored, false otherwise | 40 | - response[1] = (status >> 16) & 0xff; |
41 | + * | 41 | - response[2] = (status >> 8) & 0xff; |
42 | + * Attempt to restore the state for a fault occurring in translated | 42 | - response[3] = (status >> 0) & 0xff; |
43 | + * code. If the searched_pc is not in translated code no state is | ||
44 | + * restored and the function returns false. | ||
45 | + */ | ||
46 | bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc); | ||
47 | |||
48 | void QEMU_NORETURN cpu_loop_exit_noexc(CPUState *cpu); | ||
49 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/accel/tcg/translate-all.c | ||
52 | +++ b/accel/tcg/translate-all.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, | ||
54 | return 0; | ||
55 | } | 43 | } |
56 | 44 | ||
57 | -bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr) | 45 | static void sd_response_r3_make(SDState *sd, uint8_t *response) |
58 | +bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc) | ||
59 | { | 46 | { |
60 | TranslationBlock *tb; | 47 | - response[0] = (sd->ocr >> 24) & 0xff; |
61 | bool r = false; | 48 | - response[1] = (sd->ocr >> 16) & 0xff; |
62 | + uintptr_t check_offset; | 49 | - response[2] = (sd->ocr >> 8) & 0xff; |
63 | 50 | - response[3] = (sd->ocr >> 0) & 0xff; | |
64 | - /* A retaddr of zero is invalid so we really shouldn't have ended | 51 | + stl_be_p(response, sd->ocr); |
65 | - * up here. The target code has likely forgotten to check retaddr | 52 | } |
66 | - * != 0 before attempting to restore state. We return early to | 53 | |
67 | - * avoid blowing up on a recursive tb_lock(). The target must have | 54 | static void sd_response_r6_make(SDState *sd, uint8_t *response) |
68 | - * previously survived a failed cpu_restore_state because | 55 | { |
69 | - * tb_find_pc(0) would have failed anyway. It still should be | 56 | - uint16_t arg; |
70 | - * fixed though. | 57 | uint16_t status; |
71 | + /* The host_pc has to be in the region of current code buffer. If | 58 | |
72 | + * it is not we will not be able to resolve it here. The two cases | 59 | - arg = sd->rca; |
73 | + * where host_pc will not be correct are: | 60 | status = ((sd->card_status >> 8) & 0xc000) | |
74 | + * | 61 | ((sd->card_status >> 6) & 0x2000) | |
75 | + * - fault during translation (instruction fetch) | 62 | (sd->card_status & 0x1fff); |
76 | + * - fault from helper (not using GETPC() macro) | 63 | sd->card_status &= ~(CARD_STATUS_C & 0xc81fff); |
77 | + * | ||
78 | + * Either way we need return early to avoid blowing up on a | ||
79 | + * recursive tb_lock() as we can't resolve it here. | ||
80 | + * | ||
81 | + * We are using unsigned arithmetic so if host_pc < | ||
82 | + * tcg_init_ctx.code_gen_buffer check_offset will wrap to way | ||
83 | + * above the code_gen_buffer_size | ||
84 | */ | ||
85 | - | 64 | - |
86 | - if (!retaddr) { | 65 | - response[0] = (arg >> 8) & 0xff; |
87 | - return r; | 66 | - response[1] = arg & 0xff; |
88 | - } | 67 | - response[2] = (status >> 8) & 0xff; |
89 | - | 68 | - response[3] = status & 0xff; |
90 | - tb_lock(); | 69 | + stw_be_p(response + 0, sd->rca); |
91 | - tb = tb_find_pc(retaddr); | 70 | + stw_be_p(response + 2, status); |
92 | - if (tb) { | 71 | } |
93 | - cpu_restore_state_from_tb(cpu, tb, retaddr); | 72 | |
94 | - if (tb->cflags & CF_NOCACHE) { | 73 | static void sd_response_r7_make(SDState *sd, uint8_t *response) |
95 | - /* one-shot translation, invalidate it immediately */ | 74 | { |
96 | - tb_phys_invalidate(tb, -1); | 75 | - response[0] = (sd->vhs >> 24) & 0xff; |
97 | - tb_remove(tb); | 76 | - response[1] = (sd->vhs >> 16) & 0xff; |
98 | + check_offset = host_pc - (uintptr_t) tcg_init_ctx.code_gen_buffer; | 77 | - response[2] = (sd->vhs >> 8) & 0xff; |
99 | + | 78 | - response[3] = (sd->vhs >> 0) & 0xff; |
100 | + if (check_offset < tcg_init_ctx.code_gen_buffer_size) { | 79 | + stl_be_p(response, sd->vhs); |
101 | + tb_lock(); | 80 | } |
102 | + tb = tb_find_pc(host_pc); | 81 | |
103 | + if (tb) { | 82 | static inline uint64_t sd_addr_to_wpnum(uint64_t addr) |
104 | + cpu_restore_state_from_tb(cpu, tb, host_pc); | 83 | @@ -XXX,XX +XXX,XX @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) |
105 | + if (tb->cflags & CF_NOCACHE) { | 84 | |
106 | + /* one-shot translation, invalidate it immediately */ | 85 | static void sd_function_switch(SDState *sd, uint32_t arg) |
107 | + tb_phys_invalidate(tb, -1); | 86 | { |
108 | + tb_remove(tb); | 87 | - int i, mode, new_func, crc; |
109 | + } | 88 | + int i, mode, new_func; |
110 | + r = true; | 89 | mode = !!(arg & 0x80000000); |
111 | } | 90 | |
112 | - r = true; | 91 | sd->data[0] = 0x00; /* Maximum current consumption */ |
113 | + tb_unlock(); | 92 | @@ -XXX,XX +XXX,XX @@ static void sd_function_switch(SDState *sd, uint32_t arg) |
93 | sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4); | ||
114 | } | 94 | } |
115 | - tb_unlock(); | 95 | memset(&sd->data[17], 0, 47); |
116 | 96 | - crc = sd_crc16(sd->data, 64); | |
117 | return r; | 97 | - sd->data[65] = crc >> 8; |
98 | - sd->data[66] = crc & 0xff; | ||
99 | + stw_be_p(sd->data + 65, sd_crc16(sd->data, 64)); | ||
118 | } | 100 | } |
101 | |||
102 | static inline bool sd_wp_addr(SDState *sd, uint64_t addr) | ||
119 | -- | 103 | -- |
120 | 2.7.4 | 104 | 2.16.1 |
121 | 105 | ||
122 | 106 | diff view generated by jsdifflib |
1 | From: "Emilio G. Cota" <cota@braap.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Just like the zcu102, the ep108 can instantiate several CPUs. | 3 | use the registerfields API to access the OCR register |
4 | 4 | ||
5 | Signed-off-by: Emilio G. Cota <cota@braap.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> |
7 | Message-id: 1510343626-25861-5-git-send-email-cota@braap.org | 7 | Message-id: 20180215221325.7611-8-f4bug@amsat.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | hw/arm/xlnx-zcu102.c | 1 + | 10 | hw/sd/sd.c | 21 ++++++++++++++++----- |
11 | 1 file changed, 1 insertion(+) | 11 | 1 file changed, 16 insertions(+), 5 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | 13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/xlnx-zcu102.c | 15 | --- a/hw/sd/sd.c |
16 | +++ b/hw/arm/xlnx-zcu102.c | 16 | +++ b/hw/sd/sd.c |
17 | @@ -XXX,XX +XXX,XX @@ static void xlnx_ep108_machine_class_init(ObjectClass *oc, void *data) | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | mc->block_default_type = IF_IDE; | 18 | |
19 | mc->units_per_default_bus = 1; | 19 | //#define DEBUG_SD 1 |
20 | mc->ignore_memory_transaction_failures = true; | 20 | |
21 | + mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS; | 21 | -#define ACMD41_ENQUIRY_MASK 0x00ffffff |
22 | - | ||
23 | typedef enum { | ||
24 | sd_r0 = 0, /* no response */ | ||
25 | sd_r1, /* normal response command */ | ||
26 | @@ -XXX,XX +XXX,XX @@ static uint16_t sd_crc16(void *message, size_t width) | ||
27 | |||
28 | #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ | ||
29 | |||
30 | +FIELD(OCR, VDD_VOLTAGE_WINDOW, 0, 24) | ||
31 | +FIELD(OCR, VDD_VOLTAGE_WIN_LO, 0, 8) | ||
32 | +FIELD(OCR, DUAL_VOLTAGE_CARD, 7, 1) | ||
33 | +FIELD(OCR, VDD_VOLTAGE_WIN_HI, 8, 16) | ||
34 | +FIELD(OCR, ACCEPT_SWITCH_1V8, 24, 1) /* Only UHS-I */ | ||
35 | +FIELD(OCR, UHS_II_CARD, 29, 1) /* Only UHS-II */ | ||
36 | FIELD(OCR, CARD_CAPACITY, 30, 1) /* 0:SDSC, 1:SDHC/SDXC */ | ||
37 | FIELD(OCR, CARD_POWER_UP, 31, 1) | ||
38 | |||
39 | +#define ACMD41_ENQUIRY_MASK 0x00ffffff | ||
40 | +#define ACMD41_R3_MASK (R_OCR_VDD_VOLTAGE_WIN_HI_MASK \ | ||
41 | + | R_OCR_ACCEPT_SWITCH_1V8_MASK \ | ||
42 | + | R_OCR_UHS_II_CARD_MASK \ | ||
43 | + | R_OCR_CARD_CAPACITY_MASK \ | ||
44 | + | R_OCR_CARD_POWER_UP_MASK) | ||
45 | + | ||
46 | static void sd_set_ocr(SDState *sd) | ||
47 | { | ||
48 | - /* All voltages OK, Standard Capacity SD Memory Card, not yet powered up */ | ||
49 | - sd->ocr = 0x00ffff00; | ||
50 | + /* All voltages OK */ | ||
51 | + sd->ocr = R_OCR_VDD_VOLTAGE_WIN_HI_MASK; | ||
22 | } | 52 | } |
23 | 53 | ||
24 | static const TypeInfo xlnx_ep108_machine_init_typeinfo = { | 54 | static void sd_ocr_powerup(void *opaque) |
55 | @@ -XXX,XX +XXX,XX @@ static void sd_response_r1_make(SDState *sd, uint8_t *response) | ||
56 | |||
57 | static void sd_response_r3_make(SDState *sd, uint8_t *response) | ||
58 | { | ||
59 | - stl_be_p(response, sd->ocr); | ||
60 | + stl_be_p(response, sd->ocr & ACMD41_R3_MASK); | ||
61 | } | ||
62 | |||
63 | static void sd_response_r6_make(SDState *sd, uint8_t *response) | ||
25 | -- | 64 | -- |
26 | 2.7.4 | 65 | 2.16.1 |
27 | 66 | ||
28 | 67 | diff view generated by jsdifflib |
1 | From: Prasad J Pandit <pjp@fedoraproject.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | An 'offset' parameter sent to highbank register r/w functions | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | could be greater than number(NUM_REGS=0x200) of hb registers, | 4 | Acked-by: Alistair Francis <alistair.francis@xilinx.com> |
5 | leading to an OOB access issue. Add check to avoid it. | 5 | Message-id: 20180215221325.7611-9-f4bug@amsat.org |
6 | |||
7 | Reported-by: Moguofang (Dennis mo) <moguofang@huawei.com> | ||
8 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> | ||
9 | Message-id: 20171113062658.9697-1-ppandit@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 8 | --- |
13 | hw/arm/highbank.c | 17 +++++++++++++++-- | 9 | hw/sd/sd.c | 48 +++++++++++++++++++++++++++++++++++++++++++++--- |
14 | 1 file changed, 15 insertions(+), 2 deletions(-) | 10 | 1 file changed, 45 insertions(+), 3 deletions(-) |
15 | 11 | ||
16 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | 12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
17 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/highbank.c | 14 | --- a/hw/sd/sd.c |
19 | +++ b/hw/arm/highbank.c | 15 | +++ b/hw/sd/sd.c |
20 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ static void sd_set_rca(SDState *sd) |
21 | #include "hw/ide/ahci.h" | 17 | sd->rca += 0x4567; |
22 | #include "hw/cpu/a9mpcore.h" | ||
23 | #include "hw/cpu/a15mpcore.h" | ||
24 | +#include "qemu/log.h" | ||
25 | |||
26 | #define SMP_BOOT_ADDR 0x100 | ||
27 | #define SMP_BOOT_REG 0x40 | ||
28 | @@ -XXX,XX +XXX,XX @@ static void hb_regs_write(void *opaque, hwaddr offset, | ||
29 | } | ||
30 | } | ||
31 | |||
32 | - regs[offset/4] = value; | ||
33 | + if (offset / 4 >= NUM_REGS) { | ||
34 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
35 | + "highbank: bad write offset 0x%" HWADDR_PRIx "\n", offset); | ||
36 | + return; | ||
37 | + } | ||
38 | + regs[offset / 4] = value; | ||
39 | } | 18 | } |
40 | 19 | ||
41 | static uint64_t hb_regs_read(void *opaque, hwaddr offset, | 20 | +FIELD(CSR, AKE_SEQ_ERROR, 3, 1) |
42 | unsigned size) | 21 | +FIELD(CSR, APP_CMD, 5, 1) |
22 | +FIELD(CSR, FX_EVENT, 6, 1) | ||
23 | +FIELD(CSR, READY_FOR_DATA, 8, 1) | ||
24 | +FIELD(CSR, CURRENT_STATE, 9, 4) | ||
25 | +FIELD(CSR, ERASE_RESET, 13, 1) | ||
26 | +FIELD(CSR, CARD_ECC_DISABLED, 14, 1) | ||
27 | +FIELD(CSR, WP_ERASE_SKIP, 15, 1) | ||
28 | +FIELD(CSR, CSD_OVERWRITE, 16, 1) | ||
29 | +FIELD(CSR, DEFERRED_RESPONSE, 17, 1) | ||
30 | +FIELD(CSR, ERROR, 19, 1) | ||
31 | +FIELD(CSR, CC_ERROR, 20, 1) | ||
32 | +FIELD(CSR, CARD_ECC_FAILED, 21, 1) | ||
33 | +FIELD(CSR, ILLEGAL_COMMAND, 22, 1) | ||
34 | +FIELD(CSR, COM_CRC_ERROR, 23, 1) | ||
35 | +FIELD(CSR, LOCK_UNLOCK_FAILED, 24, 1) | ||
36 | +FIELD(CSR, CARD_IS_LOCKED, 25, 1) | ||
37 | +FIELD(CSR, WP_VIOLATION, 26, 1) | ||
38 | +FIELD(CSR, ERASE_PARAM, 27, 1) | ||
39 | +FIELD(CSR, ERASE_SEQ_ERROR, 28, 1) | ||
40 | +FIELD(CSR, BLOCK_LEN_ERROR, 29, 1) | ||
41 | +FIELD(CSR, ADDRESS_ERROR, 30, 1) | ||
42 | +FIELD(CSR, OUT_OF_RANGE, 31, 1) | ||
43 | + | ||
44 | /* Card status bits, split by clear condition: | ||
45 | * A : According to the card current state | ||
46 | * B : Always related to the previous command | ||
47 | * C : Cleared by read | ||
48 | */ | ||
49 | -#define CARD_STATUS_A 0x02004100 | ||
50 | -#define CARD_STATUS_B 0x00c01e00 | ||
51 | -#define CARD_STATUS_C 0xfd39a028 | ||
52 | +#define CARD_STATUS_A (R_CSR_READY_FOR_DATA_MASK \ | ||
53 | + | R_CSR_CARD_ECC_DISABLED_MASK \ | ||
54 | + | R_CSR_CARD_IS_LOCKED_MASK) | ||
55 | +#define CARD_STATUS_B (R_CSR_CURRENT_STATE_MASK \ | ||
56 | + | R_CSR_ILLEGAL_COMMAND_MASK \ | ||
57 | + | R_CSR_COM_CRC_ERROR_MASK) | ||
58 | +#define CARD_STATUS_C (R_CSR_AKE_SEQ_ERROR_MASK \ | ||
59 | + | R_CSR_APP_CMD_MASK \ | ||
60 | + | R_CSR_ERASE_RESET_MASK \ | ||
61 | + | R_CSR_WP_ERASE_SKIP_MASK \ | ||
62 | + | R_CSR_CSD_OVERWRITE_MASK \ | ||
63 | + | R_CSR_ERROR_MASK \ | ||
64 | + | R_CSR_CC_ERROR_MASK \ | ||
65 | + | R_CSR_CARD_ECC_FAILED_MASK \ | ||
66 | + | R_CSR_LOCK_UNLOCK_FAILED_MASK \ | ||
67 | + | R_CSR_WP_VIOLATION_MASK \ | ||
68 | + | R_CSR_ERASE_PARAM_MASK \ | ||
69 | + | R_CSR_ERASE_SEQ_ERROR_MASK \ | ||
70 | + | R_CSR_BLOCK_LEN_ERROR_MASK \ | ||
71 | + | R_CSR_ADDRESS_ERROR_MASK \ | ||
72 | + | R_CSR_OUT_OF_RANGE_MASK) | ||
73 | |||
74 | static void sd_set_cardstatus(SDState *sd) | ||
43 | { | 75 | { |
44 | + uint32_t value; | ||
45 | uint32_t *regs = opaque; | ||
46 | - uint32_t value = regs[offset/4]; | ||
47 | + | ||
48 | + if (offset / 4 >= NUM_REGS) { | ||
49 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
50 | + "highbank: bad read offset 0x%" HWADDR_PRIx "\n", offset); | ||
51 | + return 0; | ||
52 | + } | ||
53 | + value = regs[offset / 4]; | ||
54 | |||
55 | if ((offset == 0x100) || (offset == 0x108) || (offset == 0x10C)) { | ||
56 | value |= 0x30000000; | ||
57 | -- | 76 | -- |
58 | 2.7.4 | 77 | 2.16.1 |
59 | 78 | ||
60 | 79 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Linux uses it to poll the bus before polling for a card. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180215221325.7611-10-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/sd/sd.c | 5 ++--- | ||
11 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sd.c | ||
16 | +++ b/hw/sd/sd.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
18 | } | ||
19 | break; | ||
20 | |||
21 | - case 52: | ||
22 | - case 53: | ||
23 | - /* CMD52, CMD53: reserved for SDIO cards | ||
24 | + case 52 ... 54: | ||
25 | + /* CMD52, CMD53, CMD54: reserved for SDIO cards | ||
26 | * (see the SDIO Simplified Specification V2.0) | ||
27 | * Handle as illegal command but do not complain | ||
28 | * on stderr, as some OSes may use these in their | ||
29 | -- | ||
30 | 2.16.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | returning sd_illegal, since they are not implemented. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180215221325.7611-11-f4bug@amsat.org | ||
8 | [PMM: tweak multiline comment format] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/sd/sd.c | 12 ++++++++++++ | ||
12 | 1 file changed, 12 insertions(+) | ||
13 | |||
14 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/sd/sd.c | ||
17 | +++ b/hw/sd/sd.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
19 | } | ||
20 | break; | ||
21 | |||
22 | + case 18: /* Reserved for SD security applications */ | ||
23 | + case 25: | ||
24 | + case 26: | ||
25 | + case 38: | ||
26 | + case 43 ... 49: | ||
27 | + /* Refer to the "SD Specifications Part3 Security Specification" for | ||
28 | + * information about the SD Security Features. | ||
29 | + */ | ||
30 | + qemu_log_mask(LOG_UNIMP, "SD: CMD%i Security not implemented\n", | ||
31 | + req.cmd); | ||
32 | + return sd_illegal; | ||
33 | + | ||
34 | default: | ||
35 | /* Fall back to standard commands. */ | ||
36 | return sd_normal_command(sd, req); | ||
37 | -- | ||
38 | 2.16.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Suggested-by: Alistair Francis <alistair.francis@xilinx.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
6 | Message-id: 20180215221325.7611-12-f4bug@amsat.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | hw/sd/sd.c | 22 +++++++++++++--------- | ||
10 | 1 file changed, 13 insertions(+), 9 deletions(-) | ||
11 | |||
12 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/sd/sd.c | ||
15 | +++ b/hw/sd/sd.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
17 | |||
18 | /* Block write commands (Class 4) */ | ||
19 | case 24: /* CMD24: WRITE_SINGLE_BLOCK */ | ||
20 | - if (sd->spi) | ||
21 | - goto unimplemented_cmd; | ||
22 | + if (sd->spi) { | ||
23 | + goto unimplemented_spi_cmd; | ||
24 | + } | ||
25 | switch (sd->state) { | ||
26 | case sd_transfer_state: | ||
27 | /* Writing in SPI mode not implemented. */ | ||
28 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
29 | break; | ||
30 | |||
31 | case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ | ||
32 | - if (sd->spi) | ||
33 | - goto unimplemented_cmd; | ||
34 | + if (sd->spi) { | ||
35 | + goto unimplemented_spi_cmd; | ||
36 | + } | ||
37 | switch (sd->state) { | ||
38 | case sd_transfer_state: | ||
39 | /* Writing in SPI mode not implemented. */ | ||
40 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
41 | break; | ||
42 | |||
43 | case 27: /* CMD27: PROGRAM_CSD */ | ||
44 | - if (sd->spi) | ||
45 | - goto unimplemented_cmd; | ||
46 | + if (sd->spi) { | ||
47 | + goto unimplemented_spi_cmd; | ||
48 | + } | ||
49 | switch (sd->state) { | ||
50 | case sd_transfer_state: | ||
51 | sd->state = sd_receivingdata_state; | ||
52 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
53 | |||
54 | /* Lock card commands (Class 7) */ | ||
55 | case 42: /* CMD42: LOCK_UNLOCK */ | ||
56 | - if (sd->spi) | ||
57 | - goto unimplemented_cmd; | ||
58 | + if (sd->spi) { | ||
59 | + goto unimplemented_spi_cmd; | ||
60 | + } | ||
61 | switch (sd->state) { | ||
62 | case sd_transfer_state: | ||
63 | sd->state = sd_receivingdata_state; | ||
64 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
65 | qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); | ||
66 | return sd_illegal; | ||
67 | |||
68 | - unimplemented_cmd: | ||
69 | + unimplemented_spi_cmd: | ||
70 | /* Commands that are recognised but not yet implemented in SPI mode. */ | ||
71 | qemu_log_mask(LOG_UNIMP, "SD: CMD%i not implemented in SPI mode\n", | ||
72 | req.cmd); | ||
73 | -- | ||
74 | 2.16.1 | ||
75 | |||
76 | diff view generated by jsdifflib |
1 | From: "Emilio G. Cota" <cota@braap.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | 55c3cee ("qom: Introduce CPUClass.tcg_initialize", 2017-10-24) | 3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
4 | introduces a per-CPUClass bool that we check so that the target CPU | ||
5 | is initialized for TCG only once. This works well except when | ||
6 | we end up creating more than one CPUClass, in which case we end | ||
7 | up incorrectly initializing TCG more than once, i.e. once for | ||
8 | each CPUClass. | ||
9 | |||
10 | This can be replicated with: | ||
11 | $ aarch64-softmmu/qemu-system-aarch64 -machine xlnx-zcu102 -smp 6 \ | ||
12 | -global driver=xlnx,,zynqmp,property=has_rpu,value=on | ||
13 | In this case the class name of the "RPUs" is prefixed by "cortex-r5-", | ||
14 | whereas the "regular" CPUs are prefixed by "cortex-a53-". This | ||
15 | results in two CPUClass instances being created. | ||
16 | |||
17 | Fix it by introducing a static variable, so that only the first | ||
18 | target CPU being initialized will initialize the target-dependent | ||
19 | part of TCG, regardless of CPUClass instances. | ||
20 | |||
21 | Fixes: 55c3ceef61fcf06fc98ddc752b7cce788ce7680b | ||
22 | Signed-off-by: Emilio G. Cota <cota@braap.org> | ||
23 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
24 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> |
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Message-id: 20180215221325.7611-13-f4bug@amsat.org |
26 | Tested-by: Alistair Francis <alistair.francis@xilinx.com> | ||
27 | Message-id: 1510343626-25861-2-git-send-email-cota@braap.org | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | --- | 7 | --- |
30 | include/qom/cpu.h | 1 - | 8 | hw/sd/sd.c | 29 ++++++++++++++++++++++++++--- |
31 | exec.c | 5 +++-- | 9 | 1 file changed, 26 insertions(+), 3 deletions(-) |
32 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
33 | 10 | ||
34 | diff --git a/include/qom/cpu.h b/include/qom/cpu.h | 11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
35 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/include/qom/cpu.h | 13 | --- a/hw/sd/sd.c |
37 | +++ b/include/qom/cpu.h | 14 | +++ b/hw/sd/sd.c |
38 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUClass { | 15 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, |
39 | /* Keep non-pointer data at the end to minimize holes. */ | 16 | |
40 | int gdb_num_core_regs; | 17 | /* Application specific commands (Class 8) */ |
41 | bool gdb_stop_before_watchpoint; | 18 | case 55: /* CMD55: APP_CMD */ |
42 | - bool tcg_initialized; | 19 | - if (sd->rca != rca) |
43 | } CPUClass; | 20 | - return sd_r0; |
44 | 21 | - | |
45 | #ifdef HOST_WORDS_BIGENDIAN | 22 | + if (!sd->spi) { |
46 | diff --git a/exec.c b/exec.c | 23 | + if (sd->rca != rca) { |
47 | index XXXXXXX..XXXXXXX 100644 | 24 | + return sd_r0; |
48 | --- a/exec.c | 25 | + } |
49 | +++ b/exec.c | 26 | + } |
50 | @@ -XXX,XX +XXX,XX @@ void cpu_exec_initfn(CPUState *cpu) | 27 | sd->expecting_acmd = true; |
51 | void cpu_exec_realizefn(CPUState *cpu, Error **errp) | 28 | sd->card_status |= APP_CMD; |
52 | { | 29 | return sd_r1; |
53 | CPUClass *cc = CPU_GET_CLASS(cpu); | 30 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, |
54 | + static bool tcg_target_initialized; | 31 | } |
55 | 32 | break; | |
56 | cpu_list_add(cpu); | 33 | |
57 | 34 | + case 58: /* CMD58: READ_OCR (SPI) */ | |
58 | - if (tcg_enabled() && !cc->tcg_initialized) { | 35 | + if (!sd->spi) { |
59 | - cc->tcg_initialized = true; | 36 | + goto bad_cmd; |
60 | + if (tcg_enabled() && !tcg_target_initialized) { | 37 | + } |
61 | + tcg_target_initialized = true; | 38 | + return sd_r3; |
62 | cc->tcg_initialize(); | 39 | + |
40 | + case 59: /* CMD59: CRC_ON_OFF (SPI) */ | ||
41 | + if (!sd->spi) { | ||
42 | + goto bad_cmd; | ||
43 | + } | ||
44 | + goto unimplemented_spi_cmd; | ||
45 | + | ||
46 | default: | ||
47 | bad_cmd: | ||
48 | qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); | ||
49 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
50 | sd->card_status |= APP_CMD; | ||
51 | switch (req.cmd) { | ||
52 | case 6: /* ACMD6: SET_BUS_WIDTH */ | ||
53 | + if (sd->spi) { | ||
54 | + goto unimplemented_spi_cmd; | ||
55 | + } | ||
56 | switch (sd->state) { | ||
57 | case sd_transfer_state: | ||
58 | sd->sd_status[0] &= 0x3f; | ||
59 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, | ||
60 | default: | ||
61 | /* Fall back to standard commands. */ | ||
62 | return sd_normal_command(sd, req); | ||
63 | + | ||
64 | + unimplemented_spi_cmd: | ||
65 | + /* Commands that are recognised but not yet implemented in SPI mode. */ | ||
66 | + qemu_log_mask(LOG_UNIMP, "SD: CMD%i not implemented in SPI mode\n", | ||
67 | + req.cmd); | ||
68 | + return sd_illegal; | ||
63 | } | 69 | } |
64 | 70 | ||
71 | qemu_log_mask(LOG_GUEST_ERROR, "SD: ACMD%i in a wrong state\n", req.cmd); | ||
65 | -- | 72 | -- |
66 | 2.7.4 | 73 | 2.16.1 |
67 | 74 | ||
68 | 75 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215221325.7611-14-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sd.c | 8 ++++++++ | ||
9 | 1 file changed, 8 insertions(+) | ||
10 | |||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/sd/sd.c | ||
14 | +++ b/hw/sd/sd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
16 | |||
17 | /* Application specific commands (Class 8) */ | ||
18 | case 55: /* CMD55: APP_CMD */ | ||
19 | + switch (sd->state) { | ||
20 | + case sd_ready_state: | ||
21 | + case sd_identification_state: | ||
22 | + case sd_inactive_state: | ||
23 | + return sd_illegal; | ||
24 | + default: | ||
25 | + break; | ||
26 | + } | ||
27 | if (!sd->spi) { | ||
28 | if (sd->rca != rca) { | ||
29 | return sd_r0; | ||
30 | -- | ||
31 | 2.16.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
5 | Message-id: 20180215221325.7611-15-f4bug@amsat.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/sd/sd.c | 5 +++++ | ||
9 | 1 file changed, 5 insertions(+) | ||
10 | |||
11 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/sd/sd.c | ||
14 | +++ b/hw/sd/sd.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
16 | case sd_identification_state: | ||
17 | case sd_inactive_state: | ||
18 | return sd_illegal; | ||
19 | + case sd_idle_state: | ||
20 | + if (rca) { | ||
21 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
22 | + "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); | ||
23 | + } | ||
24 | default: | ||
25 | break; | ||
26 | } | ||
27 | -- | ||
28 | 2.16.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
1 | 2 | ||
3 | replace switch(single case) -> if() | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | ||
7 | Message-id: 20180215221325.7611-16-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/sd/sd.c | 26 +++++++++++--------------- | ||
11 | 1 file changed, 11 insertions(+), 15 deletions(-) | ||
12 | |||
13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/sd/sd.c | ||
16 | +++ b/hw/sd/sd.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, | ||
18 | |||
19 | case 8: /* CMD8: SEND_IF_COND */ | ||
20 | /* Physical Layer Specification Version 2.00 command */ | ||
21 | - switch (sd->state) { | ||
22 | - case sd_idle_state: | ||
23 | - sd->vhs = 0; | ||
24 | - | ||
25 | - /* No response if not exactly one VHS bit is set. */ | ||
26 | - if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { | ||
27 | - return sd->spi ? sd_r7 : sd_r0; | ||
28 | - } | ||
29 | - | ||
30 | - /* Accept. */ | ||
31 | - sd->vhs = req.arg; | ||
32 | - return sd_r7; | ||
33 | - | ||
34 | - default: | ||
35 | + if (sd->state != sd_idle_state) { | ||
36 | break; | ||
37 | } | ||
38 | - break; | ||
39 | + sd->vhs = 0; | ||
40 | + | ||
41 | + /* No response if not exactly one VHS bit is set. */ | ||
42 | + if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { | ||
43 | + return sd->spi ? sd_r7 : sd_r0; | ||
44 | + } | ||
45 | + | ||
46 | + /* Accept. */ | ||
47 | + sd->vhs = req.arg; | ||
48 | + return sd_r7; | ||
49 | |||
50 | case 9: /* CMD9: SEND_CSD */ | ||
51 | switch (sd->state) { | ||
52 | -- | ||
53 | 2.16.1 | ||
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Voluntarily add myself as maintainer for Smartfusion2 | 3 | replace switch(single case) -> if() |
4 | 4 | ||
5 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> | 6 | Reviewed-by: Alistair Francis <alistair.francis@xilinx.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20180215221325.7611-17-f4bug@amsat.org |
8 | Message-id: 1510552520-3566-1-git-send-email-sundeep.lkml@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | MAINTAINERS | 17 +++++++++++++++++ | 10 | hw/sd/sd.c | 56 ++++++++++++++++++++++++++------------------------------ |
12 | 1 file changed, 17 insertions(+) | 11 | 1 file changed, 26 insertions(+), 30 deletions(-) |
13 | 12 | ||
14 | diff --git a/MAINTAINERS b/MAINTAINERS | 13 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/MAINTAINERS | 15 | --- a/hw/sd/sd.c |
17 | +++ b/MAINTAINERS | 16 | +++ b/hw/sd/sd.c |
18 | @@ -XXX,XX +XXX,XX @@ M: Alistair Francis <alistair@alistair23.me> | 17 | @@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_app_command(SDState *sd, |
19 | S: Maintained | 18 | sd->state = sd_transfer_state; |
20 | F: hw/arm/netduino2.c | 19 | return sd_r1; |
21 | 20 | } | |
22 | +SmartFusion2 | 21 | - switch (sd->state) { |
23 | +M: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 22 | - case sd_idle_state: |
24 | +S: Maintained | 23 | - /* If it's the first ACMD41 since reset, we need to decide |
25 | +F: hw/arm/msf2-soc.c | 24 | - * whether to power up. If this is not an enquiry ACMD41, |
26 | +F: hw/misc/msf2-sysreg.c | 25 | - * we immediately report power on and proceed below to the |
27 | +F: hw/timer/mss-timer.c | 26 | - * ready state, but if it is, we set a timer to model a |
28 | +F: hw/ssi/mss-spi.c | 27 | - * delay for power up. This works around a bug in EDK2 |
29 | +F: include/hw/arm/msf2-soc.h | 28 | - * UEFI, which sends an initial enquiry ACMD41, but |
30 | +F: include/hw/misc/msf2-sysreg.h | 29 | - * assumes that the card is in ready state as soon as it |
31 | +F: include/hw/timer/mss-timer.h | 30 | - * sees the power up bit set. */ |
32 | +F: include/hw/ssi/mss-spi.h | 31 | - if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { |
32 | - if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | ||
33 | - timer_del(sd->ocr_power_timer); | ||
34 | - sd_ocr_powerup(sd); | ||
35 | - } else { | ||
36 | - trace_sdcard_inquiry_cmd41(); | ||
37 | - if (!timer_pending(sd->ocr_power_timer)) { | ||
38 | - timer_mod_ns(sd->ocr_power_timer, | ||
39 | - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
40 | - + OCR_POWER_DELAY_NS)); | ||
41 | - } | ||
42 | + if (sd->state != sd_idle_state) { | ||
43 | + break; | ||
44 | + } | ||
45 | + /* If it's the first ACMD41 since reset, we need to decide | ||
46 | + * whether to power up. If this is not an enquiry ACMD41, | ||
47 | + * we immediately report power on and proceed below to the | ||
48 | + * ready state, but if it is, we set a timer to model a | ||
49 | + * delay for power up. This works around a bug in EDK2 | ||
50 | + * UEFI, which sends an initial enquiry ACMD41, but | ||
51 | + * assumes that the card is in ready state as soon as it | ||
52 | + * sees the power up bit set. */ | ||
53 | + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { | ||
54 | + if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { | ||
55 | + timer_del(sd->ocr_power_timer); | ||
56 | + sd_ocr_powerup(sd); | ||
57 | + } else { | ||
58 | + trace_sdcard_inquiry_cmd41(); | ||
59 | + if (!timer_pending(sd->ocr_power_timer)) { | ||
60 | + timer_mod_ns(sd->ocr_power_timer, | ||
61 | + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) | ||
62 | + + OCR_POWER_DELAY_NS)); | ||
63 | } | ||
64 | } | ||
65 | + } | ||
66 | |||
67 | + if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { | ||
68 | /* We accept any voltage. 10000 V is nothing. | ||
69 | * | ||
70 | * Once we're powered up, we advance straight to ready state | ||
71 | * unless it's an enquiry ACMD41 (bits 23:0 == 0). | ||
72 | */ | ||
73 | - if (req.arg & ACMD41_ENQUIRY_MASK) { | ||
74 | - sd->state = sd_ready_state; | ||
75 | - } | ||
76 | - | ||
77 | - return sd_r3; | ||
78 | - | ||
79 | - default: | ||
80 | - break; | ||
81 | + sd->state = sd_ready_state; | ||
82 | } | ||
83 | - break; | ||
33 | + | 84 | + |
34 | +Emcraft M2S-FG484 | 85 | + return sd_r3; |
35 | +M: Subbaraya Sundeep <sundeep.lkml@gmail.com> | 86 | |
36 | +S: Maintained | 87 | case 42: /* ACMD42: SET_CLR_CARD_DETECT */ |
37 | +F: hw/arm/msf2-som.c | 88 | switch (sd->state) { |
38 | + | ||
39 | CRIS Machines | ||
40 | ------------- | ||
41 | Axis Dev88 | ||
42 | -- | 89 | -- |
43 | 2.7.4 | 90 | 2.16.1 |
44 | 91 | ||
45 | 92 | diff view generated by jsdifflib |