1
More arm patches (mostly the SDHCI ones from Philippe)
1
Arm patch queue -- these are all bug fix patches but we might
2
as well put them in to rc0...
2
3
3
thanks
4
thanks
4
-- PMM
5
-- PMM
5
6
6
The following changes since commit f521eeee3bd060b460c99e605472b7e03967db43:
7
The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be:
7
8
8
Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20180115' into staging (2018-01-15 13:17:47 +0000)
9
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000)
9
10
10
are available in the git repository at:
11
are available in the Git repository at:
11
12
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180116
13
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319
13
14
14
for you to fetch changes up to 60765b6ceeb4998a0d4220b3a53f1f185061da77:
15
for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6:
15
16
16
sdhci: add a 'dma' property to the sysbus devices (2018-01-16 13:28:21 +0000)
17
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000)
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
target-arm queue:
20
target-arm queue:
20
* SDHCI: cleanups and minor bug fixes
21
* fsl-imx6: Fix incorrect Ethernet interrupt defines
21
* target/arm: minor refactor preparatory to fp16 support
22
* dump: Update correct kdump phys_base field for AArch64
22
* omap_ssd, ssi-sd, pl181, milkymist-memcard: reset the SD
23
* char: i.MX: Add support for "TX complete" interrupt
23
card on controller reset (fixes migration failures)
24
* bcm2836/raspi: Fix various bugs resulting in panics trying
24
* target/arm: Handle page table walk load failures correctly
25
to boot a Debian Linux kernel on raspi3
25
* hw/arm/virt: Add virt-2.12 machine type
26
* get_phys_addr_pmsav7: Support AP=0b111 for v7M
27
* hw/intc/armv7m: Support byte and halfword accesses to CFSR
28
26
29
----------------------------------------------------------------
27
----------------------------------------------------------------
30
Andrey Smirnov (1):
28
Andrey Smirnov (2):
31
sdhci: Implement write method of ACMD12ERRSTS register
29
char: i.MX: Simplify imx_update()
30
char: i.MX: Add support for "TX complete" interrupt
32
31
33
Peter Maydell (8):
32
Guenter Roeck (1):
34
hw/intc/armv7m: Support byte and halfword accesses to CFSR
33
fsl-imx6: Swap Ethernet interrupt defines
35
get_phys_addr_pmsav7: Support AP=0b111 for v7M
36
hw/arm/virt: Add virt-2.12 machine type
37
target/arm: Handle page table walk load failures correctly
38
hw/sd/pl181: Reset SD card on controller reset
39
hw/sd/milkymist-memcard: Reset SD card on controller reset
40
hw/sd/ssi-sd: Reset SD card on controller reset
41
hw/sd/omap_mmc: Reset SD card on controller reset
42
34
43
Philippe Mathieu-Daudé (13):
35
Peter Maydell (9):
44
sdhci: clean up includes
36
hw/arm/raspi: Don't do board-setup or secure-boot for raspi3
45
sdhci: remove dead code
37
hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64
46
sdhci: use DEFINE_SDHCI_COMMON_PROPERTIES() for common sysbus/pci properties
38
hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE
47
sdhci: refactor common sysbus/pci class_init() into sdhci_common_class_init()
39
hw/arm/bcm2386: Fix parent type of bcm2386
48
sdhci: refactor common sysbus/pci realize() into sdhci_common_realize()
40
hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x
49
sdhci: refactor common sysbus/pci unrealize() into sdhci_common_unrealize()
41
hw/arm/bcm2836: Create proper bcm2837 device
50
sdhci: use qemu_log_mask(UNIMP) instead of fprintf()
42
hw/arm/bcm2836: Use correct affinity values for BCM2837
51
sdhci: convert the DPRINT() calls into trace events
43
hw/arm/bcm2836: Hardcode correct CPU type
52
sdhci: move MASK_TRNMOD with other SDHC_TRN* defines in "sd-internal.h"
44
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs
53
sdhci: rename the SDHC_CAPAB register
54
sdhci: fix CAPAB/MAXCURR registers, both are 64bit and read-only
55
sdhci: fix the PCI device, using the PCI address space for DMA
56
sdhci: add a 'dma' property to the sysbus devices
57
45
58
Richard Henderson (2):
46
Wei Huang (1):
59
target/arm: Split out vfp_expand_imm
47
dump: Update correct kdump phys_base field for AArch64
60
target/arm: Add fp16 support to vfp_expand_imm
61
48
62
hw/sd/sdhci-internal.h | 7 +-
49
include/hw/arm/bcm2836.h | 31 +++++++++++++---
63
include/hw/sd/sdhci.h | 19 +++-
50
include/hw/arm/fsl-imx6.h | 4 +-
64
target/arm/internals.h | 10 ++
51
include/hw/char/imx_serial.h | 3 ++
65
hw/arm/virt.c | 19 +++-
52
dump.c | 14 +++++--
66
hw/intc/armv7m_nvic.c | 38 ++++---
53
hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++-------------
67
hw/sd/milkymist-memcard.c | 4 +
54
hw/arm/boot.c | 12 ++++++
68
hw/sd/omap_mmc.c | 14 ++-
55
hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++--------
69
hw/sd/pl181.c | 4 +
56
hw/char/imx_serial.c | 44 ++++++++++++++++------
70
hw/sd/sdhci.c | 266 +++++++++++++++++++++++++++------------------
57
hw/net/imx_fec.c | 28 +++++++++++++-
71
hw/sd/ssi-sd.c | 25 ++++-
58
9 files changed, 237 insertions(+), 63 deletions(-)
72
target/arm/helper.c | 53 ++++++++-
73
target/arm/op_helper.c | 7 +-
74
target/arm/translate-a64.c | 49 ++++++---
75
hw/sd/trace-events | 14 +++
76
14 files changed, 362 insertions(+), 167 deletions(-)
77
59
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Guenter Roeck <linux@roeck-us.net>
2
2
3
Add a 'dma' property allowing machine creation to provide the address-space
3
The sabrelite machine model used by qemu-system-arm is based on the
4
SDHCI DMA operates on.
4
Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet
5
controller which is supported in QEMU using the imx_fec.c module
6
(actually called imx.enet for this model.)
5
7
6
[based on a patch from Alistair Francis <alistair.francis@xilinx.com>
8
The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the
7
from qemu/xilinx tag xilinx-v2016.1]
9
imx.enet device like this:
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
9
Message-id: 20180115182436.2066-15-f4bug@amsat.org
11
#define FSL_IMX6_ENET_MAC_1588_IRQ 118
12
#define FSL_IMX6_ENET_MAC_IRQ 119
13
14
According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf,
15
page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary,
16
interrupts are as follows.
17
18
150 ENET MAC 0 IRQ
19
151 ENET MAC 0 1588 Timer interrupt
20
21
where
22
23
150 - 32 == 118
24
151 - 32 == 119
25
26
In other words, the vector definitions in the fsl-imx6.h file are reversed.
27
28
Fixing the interrupts alone causes problems with older Linux kernels:
29
The Ethernet interface will fail to probe with Linux v4.9 and earlier.
30
Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe
31
error handling. This is a Linux kernel problem, not a qemu problem:
32
the Linux kernel only worked by accident since it requested both interrupts.
33
34
For backward compatibility, generate the Ethernet interrupt on both interrupt
35
lines. This was shown to work from all Linux kernel releases starting with
36
v3.16.
37
38
Link: https://bugs.launchpad.net/qemu/+bug/1753309
39
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
40
Message-id: 1520723090-22130-1-git-send-email-linux@roeck-us.net
41
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
43
---
12
include/hw/sd/sdhci.h | 1 +
44
include/hw/arm/fsl-imx6.h | 4 ++--
13
hw/sd/sdhci.c | 18 +++++++++++++++++-
45
hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++-
14
2 files changed, 18 insertions(+), 1 deletion(-)
46
2 files changed, 29 insertions(+), 3 deletions(-)
15
47
16
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
48
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
17
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/sd/sdhci.h
50
--- a/include/hw/arm/fsl-imx6.h
19
+++ b/include/hw/sd/sdhci.h
51
+++ b/include/hw/arm/fsl-imx6.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
52
@@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State {
21
SDBus sdbus;
53
#define FSL_IMX6_HDMI_MASTER_IRQ 115
22
MemoryRegion iomem;
54
#define FSL_IMX6_HDMI_CEC_IRQ 116
23
AddressSpace *dma_as;
55
#define FSL_IMX6_MLB150_LOW_IRQ 117
24
+ MemoryRegion *dma_mr;
56
-#define FSL_IMX6_ENET_MAC_1588_IRQ 118
25
57
-#define FSL_IMX6_ENET_MAC_IRQ 119
26
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
58
+#define FSL_IMX6_ENET_MAC_IRQ 118
27
QEMUTimer *transfer_timer;
59
+#define FSL_IMX6_ENET_MAC_1588_IRQ 119
28
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
60
#define FSL_IMX6_PCIE1_IRQ 120
61
#define FSL_IMX6_PCIE2_IRQ 121
62
#define FSL_IMX6_PCIE3_IRQ 122
63
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
29
index XXXXXXX..XXXXXXX 100644
64
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/sd/sdhci.c
65
--- a/hw/net/imx_fec.c
31
+++ b/hw/sd/sdhci.c
66
+++ b/hw/net/imx_fec.c
32
@@ -XXX,XX +XXX,XX @@ static Property sdhci_sysbus_properties[] = {
67
@@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr)
33
DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState),
68
34
DEFINE_PROP_BOOL("pending-insert-quirk", SDHCIState, pending_insert_quirk,
69
static void imx_eth_update(IMXFECState *s)
35
false),
36
+ DEFINE_PROP_LINK("dma", SDHCIState,
37
+ dma_mr, TYPE_MEMORY_REGION, MemoryRegion *),
38
DEFINE_PROP_END_OF_LIST(),
39
};
40
41
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_init(Object *obj)
42
static void sdhci_sysbus_finalize(Object *obj)
43
{
70
{
44
SDHCIState *s = SYSBUS_SDHCI(obj);
71
- if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) {
45
+
72
+ /*
46
+ if (s->dma_mr) {
73
+ * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER
47
+ object_unparent(OBJECT(s->dma_mr));
74
+ * interrupts swapped. This worked with older versions of Linux (4.14
48
+ }
75
+ * and older) since Linux associated both interrupt lines with Ethernet
49
+
76
+ * MAC interrupts. Specifically,
50
sdhci_uninitfn(s);
77
+ * - Linux 4.15 and later have separate interrupt handlers for the MAC and
51
}
78
+ * timer interrupts. Those versions of Linux fail with versions of QEMU
52
79
+ * with swapped interrupt assignments.
53
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
80
+ * - In linux 4.14, both interrupt lines were registered with the Ethernet
54
return;
81
+ * MAC interrupt handler. As a result, all versions of qemu happen to
55
}
82
+ * work, though that is accidental.
56
83
+ * - In Linux 4.9 and older, the timer interrupt was registered directly
57
- s->dma_as = &address_space_memory;
84
+ * with the Ethernet MAC interrupt handler. The MAC interrupt was
58
+ if (s->dma_mr) {
85
+ * redirected to a GPIO interrupt to work around erratum ERR006687.
59
+ address_space_init(s->dma_as, s->dma_mr, "sdhci-dma");
86
+ * This was implemented using the SOC's IOMUX block. In qemu, this GPIO
60
+ } else {
87
+ * interrupt never fired since IOMUX is currently not supported in qemu.
61
+ /* use system_memory() if property "dma" not set */
88
+ * Linux instead received MAC interrupts on the timer interrupt.
62
+ s->dma_as = &address_space_memory;
89
+ * As a result, qemu versions with the swapped interrupt assignment work,
63
+ }
90
+ * albeit accidentally, but qemu versions with the correct interrupt
64
91
+ * assignment fail.
65
sysbus_init_irq(sbd, &s->irq);
92
+ *
66
sysbus_init_mmio(sbd, &s->iomem);
93
+ * To ensure that all versions of Linux work, generate ENET_INT_MAC
67
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_unrealize(DeviceState *dev, Error **errp)
94
+ * interrrupts on both interrupt lines. This should be changed if and when
68
SDHCIState *s = SYSBUS_SDHCI(dev);
95
+ * qemu supports IOMUX.
69
96
+ */
70
sdhci_common_unrealize(s, &error_abort);
97
+ if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] &
71
+
98
+ (ENET_INT_MAC | ENET_INT_TS_TIMER)) {
72
+ if (s->dma_mr) {
99
qemu_set_irq(s->irq[1], 1);
73
+ address_space_destroy(s->dma_as);
100
} else {
74
+ }
101
qemu_set_irq(s->irq[1], 0);
75
}
76
77
static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
78
--
102
--
79
2.7.4
103
2.16.2
80
104
81
105
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Wei Huang <wei@redhat.com>
2
2
3
While SysBus devices can use the get_system_memory() address space,
3
For guest kernel that supports KASLR, the load address can change every
4
PCI devices should use the bus master address space for DMA.
4
time when guest VM runs. To find the physical base address correctly,
5
current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=".
6
However this string pattern is only available on x86_64. AArch64 uses a
7
different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure
8
QEMU dump uses the correct string on AArch64.
5
9
6
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Wei Huang <wei@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com
9
Message-id: 20180115182436.2066-14-f4bug@amsat.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
include/hw/sd/sdhci.h | 1 +
15
dump.c | 14 +++++++++++---
13
hw/sd/sdhci.c | 29 +++++++++++++++--------------
16
1 file changed, 11 insertions(+), 3 deletions(-)
14
2 files changed, 16 insertions(+), 14 deletions(-)
15
17
16
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
18
diff --git a/dump.c b/dump.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/sd/sdhci.h
20
--- a/dump.c
19
+++ b/include/hw/sd/sdhci.h
21
+++ b/dump.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
22
@@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s)
21
/*< public >*/
23
22
SDBus sdbus;
24
lines = g_strsplit((char *)vmci, "\n", -1);
23
MemoryRegion iomem;
25
for (i = 0; lines[i]; i++) {
24
+ AddressSpace *dma_as;
26
- if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) {
25
27
- if (qemu_strtou64(lines[i] + 18, NULL, 16,
26
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
28
+ const char *prefix = NULL;
27
QEMUTimer *transfer_timer;
29
+
28
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
30
+ if (s->dump_info.d_machine == EM_X86_64) {
29
index XXXXXXX..XXXXXXX 100644
31
+ prefix = "NUMBER(phys_base)=";
30
--- a/hw/sd/sdhci.c
32
+ } else if (s->dump_info.d_machine == EM_AARCH64) {
31
+++ b/hw/sd/sdhci.c
33
+ prefix = "NUMBER(PHYS_OFFSET)=";
32
@@ -XXX,XX +XXX,XX @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
34
+ }
33
s->blkcnt--;
35
+
34
}
36
+ if (prefix && g_str_has_prefix(lines[i], prefix)) {
37
+ if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16,
38
&phys_base) < 0) {
39
- warn_report("Failed to read NUMBER(phys_base)=");
40
+ warn_report("Failed to read %s", prefix);
41
} else {
42
s->dump_info.phys_base = phys_base;
35
}
43
}
36
- dma_memory_write(&address_space_memory, s->sdmasysad,
37
+ dma_memory_write(s->dma_as, s->sdmasysad,
38
&s->fifo_buffer[begin], s->data_count - begin);
39
s->sdmasysad += s->data_count - begin;
40
if (s->data_count == block_size) {
41
@@ -XXX,XX +XXX,XX @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
42
s->data_count = block_size;
43
boundary_count -= block_size - begin;
44
}
45
- dma_memory_read(&address_space_memory, s->sdmasysad,
46
+ dma_memory_read(s->dma_as, s->sdmasysad,
47
&s->fifo_buffer[begin], s->data_count - begin);
48
s->sdmasysad += s->data_count - begin;
49
if (s->data_count == block_size) {
50
@@ -XXX,XX +XXX,XX @@ static void sdhci_sdma_transfer_single_block(SDHCIState *s)
51
for (n = 0; n < datacnt; n++) {
52
s->fifo_buffer[n] = sdbus_read_data(&s->sdbus);
53
}
54
- dma_memory_write(&address_space_memory, s->sdmasysad, s->fifo_buffer,
55
- datacnt);
56
+ dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt);
57
} else {
58
- dma_memory_read(&address_space_memory, s->sdmasysad, s->fifo_buffer,
59
- datacnt);
60
+ dma_memory_read(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt);
61
for (n = 0; n < datacnt; n++) {
62
sdbus_write_data(&s->sdbus, s->fifo_buffer[n]);
63
}
64
@@ -XXX,XX +XXX,XX @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr)
65
hwaddr entry_addr = (hwaddr)s->admasysaddr;
66
switch (SDHC_DMA_TYPE(s->hostctl)) {
67
case SDHC_CTRL_ADMA2_32:
68
- dma_memory_read(&address_space_memory, entry_addr, (uint8_t *)&adma2,
69
+ dma_memory_read(s->dma_as, entry_addr, (uint8_t *)&adma2,
70
sizeof(adma2));
71
adma2 = le64_to_cpu(adma2);
72
/* The spec does not specify endianness of descriptor table.
73
@@ -XXX,XX +XXX,XX @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr)
74
dscr->incr = 8;
75
break;
76
case SDHC_CTRL_ADMA1_32:
77
- dma_memory_read(&address_space_memory, entry_addr, (uint8_t *)&adma1,
78
+ dma_memory_read(s->dma_as, entry_addr, (uint8_t *)&adma1,
79
sizeof(adma1));
80
adma1 = le32_to_cpu(adma1);
81
dscr->addr = (hwaddr)(adma1 & 0xFFFFF000);
82
@@ -XXX,XX +XXX,XX @@ static void get_adma_description(SDHCIState *s, ADMADescr *dscr)
83
}
84
break;
85
case SDHC_CTRL_ADMA2_64:
86
- dma_memory_read(&address_space_memory, entry_addr,
87
+ dma_memory_read(s->dma_as, entry_addr,
88
(uint8_t *)(&dscr->attr), 1);
89
- dma_memory_read(&address_space_memory, entry_addr + 2,
90
+ dma_memory_read(s->dma_as, entry_addr + 2,
91
(uint8_t *)(&dscr->length), 2);
92
dscr->length = le16_to_cpu(dscr->length);
93
- dma_memory_read(&address_space_memory, entry_addr + 4,
94
+ dma_memory_read(s->dma_as, entry_addr + 4,
95
(uint8_t *)(&dscr->addr), 8);
96
dscr->attr = le64_to_cpu(dscr->attr);
97
dscr->attr &= 0xfffffff8;
98
@@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s)
99
s->data_count = block_size;
100
length -= block_size - begin;
101
}
102
- dma_memory_write(&address_space_memory, dscr.addr,
103
+ dma_memory_write(s->dma_as, dscr.addr,
104
&s->fifo_buffer[begin],
105
s->data_count - begin);
106
dscr.addr += s->data_count - begin;
107
@@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s)
108
s->data_count = block_size;
109
length -= block_size - begin;
110
}
111
- dma_memory_read(&address_space_memory, dscr.addr,
112
+ dma_memory_read(s->dma_as, dscr.addr,
113
&s->fifo_buffer[begin],
114
s->data_count - begin);
115
dscr.addr += s->data_count - begin;
116
@@ -XXX,XX +XXX,XX @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
117
dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */
118
dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
119
s->irq = pci_allocate_irq(dev);
120
- pci_register_bar(dev, 0, 0, &s->iomem);
121
+ s->dma_as = pci_get_address_space(dev);
122
+ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->iomem);
123
}
124
125
static void sdhci_pci_exit(PCIDevice *dev)
126
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
127
return;
128
}
129
130
+ s->dma_as = &address_space_memory;
131
+
132
sysbus_init_irq(sbd, &s->irq);
133
sysbus_init_mmio(sbd, &s->iomem);
134
}
135
--
44
--
136
2.7.4
45
2.16.2
137
46
138
47
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
2
3
zero-initialize ADMADescr 'dscr' in sdhci_do_adma() to avoid:
3
Code of imx_update() is slightly confusing since the "flags" variable
4
doesn't really corespond to anything in real hardware and server as a
5
kitchensink accumulating events normally reported via USR1 and USR2
6
registers.
4
7
5
hw/sd/sdhci.c: In function ‘sdhci_do_adma’:
8
Change the code to explicitly evaluate state of interrupts reported
6
hw/sd/sdhci.c:714:29: error: ‘dscr.addr’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
9
via USR1 and USR2 against corresponding masking bits and use the to
7
trace_sdhci_adma("link", s->admasysaddr);
10
detemine if IRQ line should be asserted or not.
8
^
9
11
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
NOTE: Check for UTS1_TXEMPTY being set has been dropped for two
11
Acked-by: Alistair Francis <alistair.francis@xilinx.com>
13
reasons:
12
Message-id: 20180115182436.2066-9-f4bug@amsat.org
14
15
1. Emulation code implements a single character FIFO, so this flag
16
will always be set since characters are trasmitted as a part of
17
the code emulating "push" into the FIFO
18
19
2. imx_update() is really just a function doing ORing and maksing
20
of reported events, so checking for UTS1_TXEMPTY should happen,
21
if it's ever really needed should probably happen outside of
22
it.
23
24
Cc: qemu-devel@nongnu.org
25
Cc: qemu-arm@nongnu.org
26
Cc: Bill Paul <wpaul@windriver.com>
27
Cc: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
29
Message-id: 20180315191141.6789-1-andrew.smirnov@gmail.com
30
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
32
---
15
hw/sd/sdhci.c | 89 ++++++++++++++++++------------------------------------
33
hw/char/imx_serial.c | 24 ++++++++++++++++--------
16
hw/sd/trace-events | 14 +++++++++
34
1 file changed, 16 insertions(+), 8 deletions(-)
17
2 files changed, 44 insertions(+), 59 deletions(-)
18
35
19
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
36
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
20
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/sd/sdhci.c
38
--- a/hw/char/imx_serial.c
22
+++ b/hw/sd/sdhci.c
39
+++ b/hw/char/imx_serial.c
23
@@ -XXX,XX +XXX,XX @@
40
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = {
24
#include "sdhci-internal.h"
41
25
#include "qapi/error.h"
42
static void imx_update(IMXSerialState *s)
26
#include "qemu/log.h"
27
-
28
-/* host controller debug messages */
29
-#ifndef SDHC_DEBUG
30
-#define SDHC_DEBUG 0
31
-#endif
32
-
33
-#define DPRINT_L1(fmt, args...) \
34
- do { \
35
- if (SDHC_DEBUG) { \
36
- fprintf(stderr, "QEMU SDHC: " fmt, ## args); \
37
- } \
38
- } while (0)
39
-#define DPRINT_L2(fmt, args...) \
40
- do { \
41
- if (SDHC_DEBUG > 1) { \
42
- fprintf(stderr, "QEMU SDHC: " fmt, ## args); \
43
- } \
44
- } while (0)
45
-#define ERRPRINT(fmt, args...) \
46
- do { \
47
- if (SDHC_DEBUG) { \
48
- fprintf(stderr, "QEMU SDHC ERROR: " fmt, ## args); \
49
- } \
50
- } while (0)
51
+#include "trace.h"
52
53
#define TYPE_SDHCI_BUS "sdhci-bus"
54
#define SDHCI_BUS(obj) OBJECT_CHECK(SDBus, (obj), TYPE_SDHCI_BUS)
55
@@ -XXX,XX +XXX,XX @@ static void sdhci_raise_insertion_irq(void *opaque)
56
static void sdhci_set_inserted(DeviceState *dev, bool level)
57
{
43
{
58
SDHCIState *s = (SDHCIState *)dev;
44
- uint32_t flags;
59
- DPRINT_L1("Card state changed: %s!\n", level ? "insert" : "eject");
45
+ uint32_t usr1;
60
46
+ uint32_t usr2;
61
+ trace_sdhci_set_inserted(level ? "insert" : "eject");
47
+ uint32_t mask;
62
if ((s->norintsts & SDHC_NIS_REMOVE) && level) {
48
63
/* Give target some time to notice card ejection */
49
- flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY);
64
timer_mod(s->insert_timer,
50
- if (s->ucr1 & UCR1_TXMPTYEN) {
65
@@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s)
51
- flags |= (s->uts1 & UTS1_TXEMPTY);
66
s->acmd12errsts = 0;
52
- } else {
67
request.cmd = s->cmdreg >> 8;
53
- flags &= ~USR1_TRDY;
68
request.arg = s->argument;
54
- }
69
- DPRINT_L1("sending CMD%u ARG[0x%08x]\n", request.cmd, request.arg);
55
+ /*
70
+
56
+ * Lucky for us TRDY and RRDY has the same offset in both USR1 and
71
+ trace_sdhci_send_command(request.cmd, request.arg);
57
+ * UCR1, so we can get away with something as simple as the
72
rlen = sdbus_do_command(&s->sdbus, &request, response);
58
+ * following:
73
59
+ */
74
if (s->cmdreg & SDHC_CMD_RESPONSE) {
60
+ usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY);
75
@@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s)
61
+ /*
76
s->rspreg[0] = (response[0] << 24) | (response[1] << 16) |
62
+ * Bits that we want in USR2 are not as conveniently laid out,
77
(response[2] << 8) | response[3];
63
+ * unfortunately.
78
s->rspreg[1] = s->rspreg[2] = s->rspreg[3] = 0;
64
+ */
79
- DPRINT_L1("Response: RSPREG[31..0]=0x%08x\n", s->rspreg[0]);
65
+ mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
80
+ trace_sdhci_response4(s->rspreg[0]);
66
+ usr2 = s->usr2 & mask;
81
} else if (rlen == 16) {
67
82
s->rspreg[0] = (response[11] << 24) | (response[12] << 16) |
68
- qemu_set_irq(s->irq, !!flags);
83
(response[13] << 8) | response[14];
69
+ qemu_set_irq(s->irq, usr1 || usr2);
84
@@ -XXX,XX +XXX,XX @@ static void sdhci_send_command(SDHCIState *s)
85
(response[5] << 8) | response[6];
86
s->rspreg[3] = (response[0] << 16) | (response[1] << 8) |
87
response[2];
88
- DPRINT_L1("Response received:\n RSPREG[127..96]=0x%08x, RSPREG[95.."
89
- "64]=0x%08x,\n RSPREG[63..32]=0x%08x, RSPREG[31..0]=0x%08x\n",
90
- s->rspreg[3], s->rspreg[2], s->rspreg[1], s->rspreg[0]);
91
+ trace_sdhci_response16(s->rspreg[3], s->rspreg[2],
92
+ s->rspreg[1], s->rspreg[0]);
93
} else {
94
- ERRPRINT("Timeout waiting for command response\n");
95
+ trace_sdhci_error("timeout waiting for command response");
96
if (s->errintstsen & SDHC_EISEN_CMDTIMEOUT) {
97
s->errintsts |= SDHC_EIS_CMDTIMEOUT;
98
s->norintsts |= SDHC_NIS_ERR;
99
@@ -XXX,XX +XXX,XX @@ static void sdhci_end_transfer(SDHCIState *s)
100
101
request.cmd = 0x0C;
102
request.arg = 0;
103
- DPRINT_L1("Automatically issue CMD%d %08x\n", request.cmd, request.arg);
104
+ trace_sdhci_end_transfer(request.cmd, request.arg);
105
sdbus_do_command(&s->sdbus, &request, response);
106
/* Auto CMD12 response goes to the upper Response register */
107
s->rspreg[3] = (response[0] << 24) | (response[1] << 16) |
108
@@ -XXX,XX +XXX,XX @@ static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
109
110
/* first check that a valid data exists in host controller input buffer */
111
if ((s->prnsts & SDHC_DATA_AVAILABLE) == 0) {
112
- ERRPRINT("Trying to read from empty buffer\n");
113
+ trace_sdhci_error("read from empty buffer");
114
return 0;
115
}
116
117
@@ -XXX,XX +XXX,XX @@ static uint32_t sdhci_read_dataport(SDHCIState *s, unsigned size)
118
s->data_count++;
119
/* check if we've read all valid data (blksize bytes) from buffer */
120
if ((s->data_count) >= (s->blksize & 0x0fff)) {
121
- DPRINT_L2("All %u bytes of data have been read from input buffer\n",
122
- s->data_count);
123
+ trace_sdhci_read_dataport(s->data_count);
124
s->prnsts &= ~SDHC_DATA_AVAILABLE; /* no more data in a buffer */
125
s->data_count = 0; /* next buff read must start at position [0] */
126
127
@@ -XXX,XX +XXX,XX @@ static void sdhci_write_dataport(SDHCIState *s, uint32_t value, unsigned size)
128
129
/* Check that there is free space left in a buffer */
130
if (!(s->prnsts & SDHC_SPACE_AVAILABLE)) {
131
- ERRPRINT("Can't write to data buffer: buffer full\n");
132
+ trace_sdhci_error("Can't write to data buffer: buffer full");
133
return;
134
}
135
136
@@ -XXX,XX +XXX,XX @@ static void sdhci_write_dataport(SDHCIState *s, uint32_t value, unsigned size)
137
s->data_count++;
138
value >>= 8;
139
if (s->data_count >= (s->blksize & 0x0fff)) {
140
- DPRINT_L2("write buffer filled with %u bytes of data\n",
141
- s->data_count);
142
+ trace_sdhci_write_dataport(s->data_count);
143
s->data_count = 0;
144
s->prnsts &= ~SDHC_SPACE_AVAILABLE;
145
if (s->prnsts & SDHC_DOING_WRITE) {
146
@@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s)
147
{
148
unsigned int n, begin, length;
149
const uint16_t block_size = s->blksize & 0x0fff;
150
- ADMADescr dscr;
151
+ ADMADescr dscr = {};
152
int i;
153
154
for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) {
155
s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH;
156
157
get_adma_description(s, &dscr);
158
- DPRINT_L2("ADMA loop: addr=" TARGET_FMT_plx ", len=%d, attr=%x\n",
159
- dscr.addr, dscr.length, dscr.attr);
160
+ trace_sdhci_adma_loop(dscr.addr, dscr.length, dscr.attr);
161
162
if ((dscr.attr & SDHC_ADMA_ATTR_VALID) == 0) {
163
/* Indicate that error occurred in ST_FDS state */
164
@@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s)
165
break;
166
case SDHC_ADMA_ATTR_ACT_LINK: /* link to next descriptor table */
167
s->admasysaddr = dscr.addr;
168
- DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
169
- s->admasysaddr);
170
+ trace_sdhci_adma("link", s->admasysaddr);
171
break;
172
default:
173
s->admasysaddr += dscr.incr;
174
@@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s)
175
}
176
177
if (dscr.attr & SDHC_ADMA_ATTR_INT) {
178
- DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n",
179
- s->admasysaddr);
180
+ trace_sdhci_adma("interrupt", s->admasysaddr);
181
if (s->norintstsen & SDHC_NISEN_DMA) {
182
s->norintsts |= SDHC_NIS_DMA;
183
}
184
@@ -XXX,XX +XXX,XX @@ static void sdhci_do_adma(SDHCIState *s)
185
/* ADMA transfer terminates if blkcnt == 0 or by END attribute */
186
if (((s->trnmod & SDHC_TRNS_BLK_CNT_EN) &&
187
(s->blkcnt == 0)) || (dscr.attr & SDHC_ADMA_ATTR_END)) {
188
- DPRINT_L2("ADMA transfer completed\n");
189
+ trace_sdhci_adma_transfer_completed();
190
if (length || ((dscr.attr & SDHC_ADMA_ATTR_END) &&
191
(s->trnmod & SDHC_TRNS_BLK_CNT_EN) &&
192
s->blkcnt != 0)) {
193
- ERRPRINT("SD/MMC host ADMA length mismatch\n");
194
+ trace_sdhci_error("SD/MMC host ADMA length mismatch");
195
s->admaerr |= SDHC_ADMAERR_LENGTH_MISMATCH |
196
SDHC_ADMAERR_STATE_ST_TFR;
197
if (s->errintstsen & SDHC_EISEN_ADMAERR) {
198
- ERRPRINT("Set ADMA error flag\n");
199
+ trace_sdhci_error("Set ADMA error flag");
200
s->errintsts |= SDHC_EIS_ADMAERR;
201
s->norintsts |= SDHC_NIS_ERR;
202
}
203
@@ -XXX,XX +XXX,XX @@ static void sdhci_data_transfer(void *opaque)
204
break;
205
case SDHC_CTRL_ADMA1_32:
206
if (!(s->capareg & SDHC_CAN_DO_ADMA1)) {
207
- ERRPRINT("ADMA1 not supported\n");
208
+ trace_sdhci_error("ADMA1 not supported");
209
break;
210
}
211
212
@@ -XXX,XX +XXX,XX @@ static void sdhci_data_transfer(void *opaque)
213
break;
214
case SDHC_CTRL_ADMA2_32:
215
if (!(s->capareg & SDHC_CAN_DO_ADMA2)) {
216
- ERRPRINT("ADMA2 not supported\n");
217
+ trace_sdhci_error("ADMA2 not supported");
218
break;
219
}
220
221
@@ -XXX,XX +XXX,XX @@ static void sdhci_data_transfer(void *opaque)
222
case SDHC_CTRL_ADMA2_64:
223
if (!(s->capareg & SDHC_CAN_DO_ADMA2) ||
224
!(s->capareg & SDHC_64_BIT_BUS_SUPPORT)) {
225
- ERRPRINT("64 bit ADMA not supported\n");
226
+ trace_sdhci_error("64 bit ADMA not supported");
227
break;
228
}
229
230
sdhci_do_adma(s);
231
break;
232
default:
233
- ERRPRINT("Unsupported DMA type\n");
234
+ trace_sdhci_error("Unsupported DMA type");
235
break;
236
}
237
} else {
238
@@ -XXX,XX +XXX,XX @@ static inline bool
239
sdhci_buff_access_is_sequential(SDHCIState *s, unsigned byte_num)
240
{
241
if ((s->data_count & 0x3) != byte_num) {
242
- ERRPRINT("Non-sequential access to Buffer Data Port register"
243
- "is prohibited\n");
244
+ trace_sdhci_error("Non-sequential access to Buffer Data Port register"
245
+ "is prohibited\n");
246
return false;
247
}
248
return true;
249
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
250
case SDHC_BDATA:
251
if (sdhci_buff_access_is_sequential(s, offset - SDHC_BDATA)) {
252
ret = sdhci_read_dataport(s, size);
253
- DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset,
254
- ret, ret);
255
+ trace_sdhci_access("rd", size << 3, offset, "->", ret, ret);
256
return ret;
257
}
258
break;
259
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
260
261
ret >>= (offset & 0x3) * 8;
262
ret &= (1ULL << (size * 8)) - 1;
263
- DPRINT_L2("read %ub: addr[0x%04x] -> %u(0x%x)\n", size, (int)offset, ret, ret);
264
+ trace_sdhci_access("rd", size << 3, offset, "->", ret, ret);
265
return ret;
266
}
70
}
267
71
268
@@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
72
static void imx_serial_reset(IMXSerialState *s)
269
"not implemented\n", size, offset, value >> shift);
270
break;
271
}
272
- DPRINT_L2("write %ub: addr[0x%04x] <- %u(0x%x)\n",
273
- size, (int)offset, value >> shift, value >> shift);
274
+ trace_sdhci_access("wr", size << 3, offset, "<-",
275
+ value >> shift, value >> shift);
276
}
277
278
static const MemoryRegionOps sdhci_mmio_ops = {
279
diff --git a/hw/sd/trace-events b/hw/sd/trace-events
280
index XXXXXXX..XXXXXXX 100644
281
--- a/hw/sd/trace-events
282
+++ b/hw/sd/trace-events
283
@@ -XXX,XX +XXX,XX @@
284
# See docs/devel/tracing.txt for syntax documentation.
285
286
+# hw/sd/sdhci.c
287
+sdhci_set_inserted(const char *level) "card state changed: %s"
288
+sdhci_send_command(uint8_t cmd, uint32_t arg) "CMD%02u ARG[0x%08x]"
289
+sdhci_error(const char *msg) "%s"
290
+sdhci_response4(uint32_t r0) "RSPREG[31..0]=0x%08x"
291
+sdhci_response16(uint32_t r3, uint32_t r2, uint32_t r1, uint32_t r0) "RSPREG[127..96]=0x%08x, RSPREG[95..64]=0x%08x, RSPREG[63..32]=0x%08x, RSPREG[31..0]=0x%08x"
292
+sdhci_end_transfer(uint8_t cmd, uint32_t arg) "Automatically issue CMD%02u 0x%08x"
293
+sdhci_adma(const char *desc, uint32_t sysad) "%s: admasysaddr=0x%" PRIx32
294
+sdhci_adma_loop(uint64_t addr, uint16_t length, uint8_t attr) "addr=0x%08" PRIx64 ", len=%d, attr=0x%x"
295
+sdhci_adma_transfer_completed(void) ""
296
+sdhci_access(const char *access, unsigned int size, uint64_t offset, const char *dir, uint64_t val, uint64_t val2) "%s%u: addr[0x%04" PRIx64 "] %s 0x%08" PRIx64 " (%" PRIu64 ")"
297
+sdhci_read_dataport(uint16_t data_count) "all %u bytes of data have been read from input buffer"
298
+sdhci_write_dataport(uint16_t data_count) "write buffer filled with %u bytes of data"
299
+
300
# hw/sd/milkymist-memcard.c
301
milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
302
milkymist_memcard_memory_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
303
--
73
--
304
2.7.4
74
2.16.2
305
75
306
76
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
2
3
Add support for "TX complete"/TXDC interrupt generate by real HW since
4
it is needed to support guests other than Linux.
5
6
Based on the patch by Bill Paul as found here:
7
https://bugs.launchpad.net/qemu/+bug/1753314
8
9
Cc: qemu-devel@nongnu.org
10
Cc: qemu-arm@nongnu.org
11
Cc: Bill Paul <wpaul@windriver.com>
12
Cc: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Bill Paul <wpaul@windriver.com>
3
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
14
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
15
Message-id: 20180315191141.6789-2-andrew.smirnov@gmail.com
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
7
Message-id: 20180115182436.2066-13-f4bug@amsat.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
18
---
10
hw/sd/sdhci.c | 3 +++
19
include/hw/char/imx_serial.h | 3 +++
11
1 file changed, 3 insertions(+)
20
hw/char/imx_serial.c | 20 +++++++++++++++++---
21
2 files changed, 20 insertions(+), 3 deletions(-)
12
22
13
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
23
diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h
14
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/sd/sdhci.c
25
--- a/include/hw/char/imx_serial.h
16
+++ b/hw/sd/sdhci.c
26
+++ b/include/hw/char/imx_serial.h
17
@@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
27
@@ -XXX,XX +XXX,XX @@
28
#define UCR2_RXEN (1<<1) /* Receiver enable */
29
#define UCR2_SRST (1<<0) /* Reset complete */
30
31
+#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */
32
+
33
#define UTS1_TXEMPTY (1<<6)
34
#define UTS1_RXEMPTY (1<<5)
35
#define UTS1_TXFULL (1<<4)
36
@@ -XXX,XX +XXX,XX @@ typedef struct IMXSerialState {
37
uint32_t ubmr;
38
uint32_t ubrc;
39
uint32_t ucr3;
40
+ uint32_t ucr4;
41
42
qemu_irq irq;
43
CharBackend chr;
44
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/char/imx_serial.c
47
+++ b/hw/char/imx_serial.c
48
@@ -XXX,XX +XXX,XX @@
49
50
static const VMStateDescription vmstate_imx_serial = {
51
.name = TYPE_IMX_SERIAL,
52
- .version_id = 1,
53
- .minimum_version_id = 1,
54
+ .version_id = 2,
55
+ .minimum_version_id = 2,
56
.fields = (VMStateField[]) {
57
VMSTATE_INT32(readbuff, IMXSerialState),
58
VMSTATE_UINT32(usr1, IMXSerialState),
59
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = {
60
VMSTATE_UINT32(ubmr, IMXSerialState),
61
VMSTATE_UINT32(ubrc, IMXSerialState),
62
VMSTATE_UINT32(ucr3, IMXSerialState),
63
+ VMSTATE_UINT32(ucr4, IMXSerialState),
64
VMSTATE_END_OF_LIST()
65
},
66
};
67
@@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s)
68
* unfortunately.
69
*/
70
mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
71
+ /*
72
+ * TCEN and TXDC are both bit 3
73
+ */
74
+ mask |= s->ucr4 & UCR4_TCEN;
75
+
76
usr2 = s->usr2 & mask;
77
78
qemu_set_irq(s->irq, usr1 || usr2);
79
@@ -XXX,XX +XXX,XX @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
80
return s->ucr3;
81
82
case 0x23: /* UCR4 */
83
+ return s->ucr4;
84
+
85
case 0x29: /* BRM Incremental */
86
return 0x0; /* TODO */
87
88
@@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset,
89
* qemu_chr_fe_write and background I/O callbacks */
90
qemu_chr_fe_write_all(&s->chr, &ch, 1);
91
s->usr1 &= ~USR1_TRDY;
92
+ s->usr2 &= ~USR2_TXDC;
93
imx_update(s);
94
s->usr1 |= USR1_TRDY;
95
+ s->usr2 |= USR2_TXDC;
96
imx_update(s);
18
}
97
}
19
sdhci_update_irq(s);
20
break;
98
break;
21
+ case SDHC_ACMD12ERRSTS:
99
@@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset,
22
+ MASKED_WRITE(s->acmd12errsts, mask, value);
100
s->ucr3 = value & 0xffff;
101
break;
102
103
- case 0x2d: /* UTS1 */
104
case 0x23: /* UCR4 */
105
+ s->ucr4 = value & 0xffff;
106
+ imx_update(s);
23
+ break;
107
+ break;
24
108
+
25
case SDHC_CAPAB:
109
+ case 0x2d: /* UTS1 */
26
case SDHC_CAPAB + 4:
110
qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
111
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
112
/* TODO */
27
--
113
--
28
2.7.4
114
2.16.2
29
115
30
116
diff view generated by jsdifflib
1
Add virt-2.12 machine type.
1
For the rpi1 and 2 we want to boot the Linux kernel via some
2
custom setup code that makes sure that the SMC instruction
3
acts as a no-op, because it's used for cache maintenance.
4
The rpi3 boots AArch64 kernels, which don't need SMC for
5
cache maintenance and always expect to be booted non-secure.
6
Don't fill in the aarch32-specific parts of the binfo struct.
2
7
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20180313153458.26822-2-peter.maydell@linaro.org
4
---
12
---
5
hw/arm/virt.c | 19 +++++++++++++++++--
13
hw/arm/raspi.c | 17 +++++++++++++----
6
1 file changed, 17 insertions(+), 2 deletions(-)
14
1 file changed, 13 insertions(+), 4 deletions(-)
7
15
8
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
9
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
10
--- a/hw/arm/virt.c
18
--- a/hw/arm/raspi.c
11
+++ b/hw/arm/virt.c
19
+++ b/hw/arm/raspi.c
12
@@ -XXX,XX +XXX,XX @@ static void machvirt_machine_init(void)
20
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
13
}
21
binfo.board_id = raspi_boardid[version];
14
type_init(machvirt_machine_init);
22
binfo.ram_size = ram_size;
15
23
binfo.nb_cpus = smp_cpus;
16
-static void virt_2_11_instance_init(Object *obj)
24
- binfo.board_setup_addr = BOARDSETUP_ADDR;
17
+static void virt_2_12_instance_init(Object *obj)
25
- binfo.write_board_setup = write_board_setup;
18
{
26
- binfo.secure_board_setup = true;
19
VirtMachineState *vms = VIRT_MACHINE(obj);
27
- binfo.secure_boot = true;
20
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
21
@@ -XXX,XX +XXX,XX @@ static void virt_2_11_instance_init(Object *obj)
22
vms->irqmap = a15irqmap;
23
}
24
25
+static void virt_machine_2_12_options(MachineClass *mc)
26
+{
27
+}
28
+DEFINE_VIRT_MACHINE_AS_LATEST(2, 12)
29
+
28
+
30
+#define VIRT_COMPAT_2_11 \
29
+ if (version <= 2) {
31
+ HW_COMPAT_2_11
30
+ /* The rpi1 and 2 require some custom setup code to run in Secure
32
+
31
+ * mode before booting a kernel (to set up the SMC vectors so
33
+static void virt_2_11_instance_init(Object *obj)
32
+ * that we get a no-op SMC; this is used by Linux to call the
34
+{
33
+ * firmware for some cache maintenance operations.
35
+ virt_2_12_instance_init(obj);
34
+ * The rpi3 doesn't need this.
36
+}
35
+ */
37
+
36
+ binfo.board_setup_addr = BOARDSETUP_ADDR;
38
static void virt_machine_2_11_options(MachineClass *mc)
37
+ binfo.write_board_setup = write_board_setup;
39
{
38
+ binfo.secure_board_setup = true;
40
+ virt_machine_2_12_options(mc);
39
+ binfo.secure_boot = true;
41
+ SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_11);
40
+ }
42
}
41
43
-DEFINE_VIRT_MACHINE_AS_LATEST(2, 11)
42
/* Pi2 and Pi3 requires SMP setup */
44
+DEFINE_VIRT_MACHINE(2, 11)
43
if (version >= 2) {
45
46
#define VIRT_COMPAT_2_10 \
47
HW_COMPAT_2_10
48
--
44
--
49
2.7.4
45
2.16.2
50
46
51
47
diff view generated by jsdifflib
1
Since milkymist-memcard is still using the legacy SD card API,
1
Add some assertions that if we're about to boot an AArch64 kernel,
2
the SD card created by sd_init() is not plugged into any bus.
2
the board code has not mistakenly set either secure_boot or
3
This means that the controller has to reset it manually.
3
secure_board_setup. It doesn't make sense to set secure_boot,
4
because all AArch64 kernels must be booted in non-secure mode.
4
5
5
Failing to do this mostly didn't affect the guest since the
6
It might in theory make sense to set secure_board_setup, but
6
guest typically does a programmed SD card reset as part of
7
we don't currently support that, because only the AArch32
7
its SD controller driver initialization, but meant that
8
bootloader[] code calls this hook; bootloader_aarch64[] does not.
8
migration failed because it's only in sd_reset() that we
9
Since we don't have a current need for this functionality, just
9
set up the wpgrps_size field.
10
assert that we don't try to use it. If it's needed we'll add
11
it later.
10
12
11
Cc: qemu-stable@nongnu.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20180313153458.26822-3-peter.maydell@linaro.org
15
Message-id: 1515506513-31961-3-git-send-email-peter.maydell@linaro.org
16
---
16
---
17
hw/sd/milkymist-memcard.c | 4 ++++
17
hw/arm/boot.c | 7 +++++++
18
1 file changed, 4 insertions(+)
18
1 file changed, 7 insertions(+)
19
19
20
diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
20
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
21
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/sd/milkymist-memcard.c
22
--- a/hw/arm/boot.c
23
+++ b/hw/sd/milkymist-memcard.c
23
+++ b/hw/arm/boot.c
24
@@ -XXX,XX +XXX,XX @@ static void milkymist_memcard_reset(DeviceState *d)
24
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
25
for (i = 0; i < R_MAX; i++) {
25
} else {
26
s->regs[i] = 0;
26
env->pstate = PSTATE_MODE_EL1h;
27
}
27
}
28
+ /* Since we're still using the legacy SD API the card is not plugged
28
+ /* AArch64 kernels never boot in secure mode */
29
+ * into any bus, and we must reset it manually.
29
+ assert(!info->secure_boot);
30
+ */
30
+ /* This hook is only supported for AArch32 currently:
31
+ device_reset(DEVICE(s->card));
31
+ * bootloader_aarch64[] will not call the hook, and
32
}
32
+ * the code above has already dropped us into EL2 or EL1.
33
33
+ */
34
static int milkymist_memcard_init(SysBusDevice *dev)
34
+ assert(!info->secure_board_setup);
35
}
36
37
/* Set to non-secure if not a secure boot */
35
--
38
--
36
2.7.4
39
2.16.2
37
40
38
41
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
If we're directly booting a Linux kernel and the CPU supports both
2
EL3 and EL2, we start the kernel in EL2, as it expects. We must also
3
set the SCR_EL3.HCE bit in this situation, so that the HVC
4
instruction is enabled rather than UNDEFing. Otherwise at least some
5
kernels will panic when trying to initialize KVM in the guest.
2
6
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20180110063337.21538-3-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20180313153458.26822-4-peter.maydell@linaro.org
7
---
9
---
8
target/arm/translate-a64.c | 5 +++++
10
hw/arm/boot.c | 5 +++++
9
1 file changed, 5 insertions(+)
11
1 file changed, 5 insertions(+)
10
12
11
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
13
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/translate-a64.c
15
--- a/hw/arm/boot.c
14
+++ b/target/arm/translate-a64.c
16
+++ b/hw/arm/boot.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t vfp_expand_imm(int size, uint8_t imm8)
17
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
16
(extract32(imm8, 0, 6) << 3);
18
assert(!info->secure_board_setup);
17
imm <<= 16;
19
}
18
break;
20
19
+ case MO_16:
21
+ if (arm_feature(env, ARM_FEATURE_EL2)) {
20
+ imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
22
+ /* If we have EL2 then Linux expects the HVC insn to work */
21
+ (extract32(imm8, 6, 1) ? 0x3000 : 0x4000) |
23
+ env->cp15.scr_el3 |= SCR_HCE;
22
+ (extract32(imm8, 0, 6) << 6);
24
+ }
23
+ break;
25
+
24
default:
26
/* Set to non-secure if not a secure boot */
25
g_assert_not_reached();
27
if (!info->secure_boot &&
26
}
28
(cs != first_cpu || !info->secure_board_setup)) {
27
--
29
--
28
2.7.4
30
2.16.2
29
31
30
32
diff view generated by jsdifflib
1
The Configurable Fault Status Register for ARMv7M and v8M is
1
The TypeInfo and state struct for bcm2386 disagree about what the
2
supposed to be byte and halfword accessible, but we were only
2
parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE,
3
implementing word accesses. Add support for the other access
3
but the BCM2386State struct only defines the parent_obj field
4
sizes, which are used by the Zephyr RTOS.
4
as DeviceState. This would have caused problems if anything
5
actually tried to treat the object as a TYPE_SYS_BUS_DEVICE.
6
Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't
7
need any of the additional functionality TYPE_SYS_BUS_DEVICE
8
provides.
5
9
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reported-by: Andy Gross <andy.gross@linaro.org>
11
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 1512742372-31517-1-git-send-email-peter.maydell@linaro.org
13
Message-id: 20180313153458.26822-5-peter.maydell@linaro.org
10
---
14
---
11
hw/intc/armv7m_nvic.c | 38 ++++++++++++++++++++++----------------
15
hw/arm/bcm2836.c | 2 +-
12
1 file changed, 22 insertions(+), 16 deletions(-)
16
1 file changed, 1 insertion(+), 1 deletion(-)
13
17
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
18
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
15
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
20
--- a/hw/arm/bcm2836.c
17
+++ b/hw/intc/armv7m_nvic.c
21
+++ b/hw/arm/bcm2836.c
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
22
@@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
19
val |= (1 << 8);
23
20
}
24
static const TypeInfo bcm2836_type_info = {
21
return val;
25
.name = TYPE_BCM2836,
22
- case 0xd28: /* Configurable Fault Status. */
26
- .parent = TYPE_SYS_BUS_DEVICE,
23
- /* The BFSR bits [15:8] are shared between security states
27
+ .parent = TYPE_DEVICE,
24
- * and we store them in the NS copy
28
.instance_size = sizeof(BCM2836State),
25
- */
29
.instance_init = bcm2836_init,
26
- val = cpu->env.v7m.cfsr[attrs.secure];
30
.class_init = bcm2836_class_init,
27
- val |= cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
28
- return val;
29
case 0xd2c: /* Hard Fault Status. */
30
return cpu->env.v7m.hfsr;
31
case 0xd30: /* Debug Fault Status. */
32
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
33
s->vectors[ARMV7M_EXCP_DEBUG].active = (value & (1 << 8)) != 0;
34
nvic_irq_update(s);
35
break;
36
- case 0xd28: /* Configurable Fault Status. */
37
- cpu->env.v7m.cfsr[attrs.secure] &= ~value; /* W1C */
38
- if (attrs.secure) {
39
- /* The BFSR bits [15:8] are shared between security states
40
- * and we store them in the NS copy.
41
- */
42
- cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK);
43
- }
44
- break;
45
case 0xd2c: /* Hard Fault Status. */
46
cpu->env.v7m.hfsr &= ~value; /* W1C */
47
break;
48
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
49
val = deposit32(val, i * 8, 8, get_prio(s, hdlidx, sbank));
50
}
51
break;
52
+ case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */
53
+ /* The BFSR bits [15:8] are shared between security states
54
+ * and we store them in the NS copy
55
+ */
56
+ val = s->cpu->env.v7m.cfsr[attrs.secure];
57
+ val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
58
+ val = extract32(val, (offset - 0xd28) * 8, size * 8);
59
+ break;
60
case 0xfe0 ... 0xfff: /* ID. */
61
if (offset & 3) {
62
val = 0;
63
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
64
}
65
nvic_irq_update(s);
66
return MEMTX_OK;
67
+ case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */
68
+ /* All bits are W1C, so construct 32 bit value with 0s in
69
+ * the parts not written by the access size
70
+ */
71
+ value <<= ((offset - 0xd28) * 8);
72
+
73
+ s->cpu->env.v7m.cfsr[attrs.secure] &= ~value;
74
+ if (attrs.secure) {
75
+ /* The BFSR bits [15:8] are shared between security states
76
+ * and we store them in the NS copy.
77
+ */
78
+ s->cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK);
79
+ }
80
+ return MEMTX_OK;
81
}
82
if (size == 4) {
83
nvic_writel(s, offset, value, attrs);
84
--
31
--
85
2.7.4
32
2.16.2
86
33
87
34
diff view generated by jsdifflib
Deleted patch
1
For PMSAv7, the v7A/R Arm ARM defines that setting AP to 0b111
2
is an UNPREDICTABLE reserved combination. However, for v7M
3
this value is documented as having the same behaviour as 0b110:
4
read-only for both privileged and unprivileged. Accept this
5
value on an M profile core rather than treating it as a guest
6
error and a no-access page.
7
1
8
Reported-by: Andy Gross <andy.gross@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 1512742402-31669-1-git-send-email-peter.maydell@linaro.org
12
---
13
target/arm/helper.c | 14 ++++++++++++++
14
1 file changed, 14 insertions(+)
15
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
19
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
21
case 6:
22
*prot |= PAGE_READ | PAGE_EXEC;
23
break;
24
+ case 7:
25
+ /* for v7M, same as 6; for R profile a reserved value */
26
+ if (arm_feature(env, ARM_FEATURE_M)) {
27
+ *prot |= PAGE_READ | PAGE_EXEC;
28
+ break;
29
+ }
30
+ /* fall through */
31
default:
32
qemu_log_mask(LOG_GUEST_ERROR,
33
"DRACR[%d]: Bad value for AP bits: 0x%"
34
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
35
case 6:
36
*prot |= PAGE_READ | PAGE_EXEC;
37
break;
38
+ case 7:
39
+ /* for v7M, same as 6; for R profile a reserved value */
40
+ if (arm_feature(env, ARM_FEATURE_M)) {
41
+ *prot |= PAGE_READ | PAGE_EXEC;
42
+ break;
43
+ }
44
+ /* fall through */
45
default:
46
qemu_log_mask(LOG_GUEST_ERROR,
47
"DRACR[%d]: Bad value for AP bits: 0x%"
48
--
49
2.7.4
50
51
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
Our BCM2836 type is really a generic one that can be any of
2
the bcm283x family. Rename it accordingly. We change only
3
the names which are visible via the header file to the
4
rest of the QEMU code, leaving private function names
5
in bcm2836.c as they are.
2
6
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
This is a preliminary to making bcm283x be an abstract
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
8
parent class to specific types for the bcm2836 and bcm2837.
5
Message-id: 20180115182436.2066-7-f4bug@amsat.org
9
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180313153458.26822-6-peter.maydell@linaro.org
7
---
14
---
8
hw/sd/sdhci.c | 22 ++++++++++++++++++++++
15
include/hw/arm/bcm2836.h | 12 ++++++------
9
1 file changed, 22 insertions(+)
16
hw/arm/bcm2836.c | 17 +++++++++--------
17
hw/arm/raspi.c | 16 ++++++++--------
18
3 files changed, 23 insertions(+), 22 deletions(-)
10
19
11
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
20
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
12
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/sdhci.c
22
--- a/include/hw/arm/bcm2836.h
14
+++ b/hw/sd/sdhci.c
23
+++ b/include/hw/arm/bcm2836.h
15
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
16
#include "qemu/bitops.h"
25
#include "hw/arm/bcm2835_peripherals.h"
17
#include "hw/sd/sdhci.h"
26
#include "hw/intc/bcm2836_control.h"
18
#include "sdhci-internal.h"
27
19
+#include "qapi/error.h"
28
-#define TYPE_BCM2836 "bcm2836"
20
#include "qemu/log.h"
29
-#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836)
21
30
+#define TYPE_BCM283X "bcm283x"
22
/* host controller debug messages */
31
+#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X)
23
@@ -XXX,XX +XXX,XX @@ static void sdhci_common_realize(SDHCIState *s, Error **errp)
32
24
SDHC_REGISTERS_MAP_SIZE);
33
-#define BCM2836_NCPUS 4
34
+#define BCM283X_NCPUS 4
35
36
-typedef struct BCM2836State {
37
+typedef struct BCM283XState {
38
/*< private >*/
39
DeviceState parent_obj;
40
/*< public >*/
41
@@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State {
42
char *cpu_type;
43
uint32_t enabled_cpus;
44
45
- ARMCPU cpus[BCM2836_NCPUS];
46
+ ARMCPU cpus[BCM283X_NCPUS];
47
BCM2836ControlState control;
48
BCM2835PeripheralState peripherals;
49
-} BCM2836State;
50
+} BCM283XState;
51
52
#endif /* BCM2836_H */
53
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/arm/bcm2836.c
56
+++ b/hw/arm/bcm2836.c
57
@@ -XXX,XX +XXX,XX @@
58
59
static void bcm2836_init(Object *obj)
60
{
61
- BCM2836State *s = BCM2836(obj);
62
+ BCM283XState *s = BCM283X(obj);
63
64
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
65
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
66
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
67
68
static void bcm2836_realize(DeviceState *dev, Error **errp)
69
{
70
- BCM2836State *s = BCM2836(dev);
71
+ BCM283XState *s = BCM283X(dev);
72
Object *obj;
73
Error *err = NULL;
74
int n;
75
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
76
/* common peripherals from bcm2835 */
77
78
obj = OBJECT(dev);
79
- for (n = 0; n < BCM2836_NCPUS; n++) {
80
+ for (n = 0; n < BCM283X_NCPUS; n++) {
81
object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
82
s->cpu_type);
83
object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
84
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
85
sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1,
86
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
87
88
- for (n = 0; n < BCM2836_NCPUS; n++) {
89
+ for (n = 0; n < BCM283X_NCPUS; n++) {
90
/* Mirror bcm2836, which has clusterid set to 0xf
91
* TODO: this should be converted to a property of ARM_CPU
92
*/
93
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
25
}
94
}
26
95
27
+static void sdhci_common_unrealize(SDHCIState *s, Error **errp)
96
static Property bcm2836_props[] = {
28
+{
97
- DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type),
29
+ /* This function is expected to be called only once for each class:
98
- DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS),
30
+ * - SysBus: via DeviceClass->unrealize(),
99
+ DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type),
31
+ * - PCI: via PCIDeviceClass->exit().
100
+ DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
32
+ * However to avoid double-free and/or use-after-free we still nullify
101
+ BCM283X_NCPUS),
33
+ * this variable (better safe than sorry!). */
102
DEFINE_PROP_END_OF_LIST()
34
+ g_free(s->fifo_buffer);
103
};
35
+ s->fifo_buffer = NULL;
104
36
+}
105
@@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
37
+
38
static bool sdhci_pending_insert_vmstate_needed(void *opaque)
39
{
40
SDHCIState *s = opaque;
41
@@ -XXX,XX +XXX,XX @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
42
static void sdhci_pci_exit(PCIDevice *dev)
43
{
44
SDHCIState *s = PCI_SDHCI(dev);
45
+
46
+ sdhci_common_unrealize(s, &error_abort);
47
sdhci_uninitfn(s);
48
}
106
}
49
107
50
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
108
static const TypeInfo bcm2836_type_info = {
51
sysbus_init_mmio(sbd, &s->iomem);
109
- .name = TYPE_BCM2836,
110
+ .name = TYPE_BCM283X,
111
.parent = TYPE_DEVICE,
112
- .instance_size = sizeof(BCM2836State),
113
+ .instance_size = sizeof(BCM283XState),
114
.instance_init = bcm2836_init,
115
.class_init = bcm2836_class_init,
116
};
117
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
118
index XXXXXXX..XXXXXXX 100644
119
--- a/hw/arm/raspi.c
120
+++ b/hw/arm/raspi.c
121
@@ -XXX,XX +XXX,XX @@
122
static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
123
124
typedef struct RasPiState {
125
- BCM2836State soc;
126
+ BCM283XState soc;
127
MemoryRegion ram;
128
} RasPiState;
129
130
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
131
BusState *bus;
132
DeviceState *carddev;
133
134
- object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836);
135
+ object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X);
136
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
137
&error_abort);
138
139
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
140
mc->no_floppy = 1;
141
mc->no_cdrom = 1;
142
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
143
- mc->max_cpus = BCM2836_NCPUS;
144
- mc->min_cpus = BCM2836_NCPUS;
145
- mc->default_cpus = BCM2836_NCPUS;
146
+ mc->max_cpus = BCM283X_NCPUS;
147
+ mc->min_cpus = BCM283X_NCPUS;
148
+ mc->default_cpus = BCM283X_NCPUS;
149
mc->default_ram_size = 1024 * 1024 * 1024;
150
mc->ignore_memory_transaction_failures = true;
151
};
152
@@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc)
153
mc->no_floppy = 1;
154
mc->no_cdrom = 1;
155
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53");
156
- mc->max_cpus = BCM2836_NCPUS;
157
- mc->min_cpus = BCM2836_NCPUS;
158
- mc->default_cpus = BCM2836_NCPUS;
159
+ mc->max_cpus = BCM283X_NCPUS;
160
+ mc->min_cpus = BCM283X_NCPUS;
161
+ mc->default_cpus = BCM283X_NCPUS;
162
mc->default_ram_size = 1024 * 1024 * 1024;
52
}
163
}
53
164
DEFINE_MACHINE("raspi3", raspi3_machine_init)
54
+static void sdhci_sysbus_unrealize(DeviceState *dev, Error **errp)
55
+{
56
+ SDHCIState *s = SYSBUS_SDHCI(dev);
57
+
58
+ sdhci_common_unrealize(s, &error_abort);
59
+}
60
+
61
static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
62
{
63
DeviceClass *dc = DEVICE_CLASS(klass);
64
65
dc->props = sdhci_sysbus_properties;
66
dc->realize = sdhci_sysbus_realize;
67
+ dc->unrealize = sdhci_sysbus_unrealize;
68
69
sdhci_common_class_init(klass, data);
70
}
71
--
165
--
72
2.7.4
166
2.16.2
73
167
74
168
diff view generated by jsdifflib
1
Since omap_mmc is still using the legacy SD card API, the SD
1
The bcm2837 is pretty similar to the bcm2836, but it does have
2
card created by sd_init() is not plugged into any bus. This
2
some differences. Notably, the MPIDR affinity aff1 values it
3
means that the controller has to reset it manually.
3
sets for the CPUs are 0x0, rather than the 0xf that the bcm2836
4
uses, and if this is wrong Linux will not boot.
4
5
5
Failing to do this mostly didn't affect the guest since the
6
Rather than trying to have one device with properties that
6
guest typically does a programmed SD card reset as part of
7
configure it differently for the two cases, create two
7
its SD controller driver initialization, but would mean that
8
separate QOM devices for the two SoCs. We use the same approach
8
migration fails because it's only in sd_reset() that we
9
as hw/arm/aspeed_soc.c and share code and have a data table
9
set up the wpgrps_size field.
10
that might differ per-SoC. For the moment the two types don't
11
actually have different behaviour.
10
12
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20180313153458.26822-7-peter.maydell@linaro.org
14
Message-id: 1515506513-31961-5-git-send-email-peter.maydell@linaro.org
15
---
16
---
16
hw/sd/omap_mmc.c | 14 ++++++++++----
17
include/hw/arm/bcm2836.h | 19 +++++++++++++++++++
17
1 file changed, 10 insertions(+), 4 deletions(-)
18
hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++-----
19
hw/arm/raspi.c | 3 ++-
20
3 files changed, 53 insertions(+), 6 deletions(-)
18
21
19
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
22
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
20
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/sd/omap_mmc.c
24
--- a/include/hw/arm/bcm2836.h
22
+++ b/hw/sd/omap_mmc.c
25
+++ b/include/hw/arm/bcm2836.h
23
@@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host)
26
@@ -XXX,XX +XXX,XX @@
24
host->cdet_enable = 0;
27
25
qemu_set_irq(host->coverswitch, host->cdet_state);
28
#define BCM283X_NCPUS 4
26
host->clkdiv = 0;
29
30
+/* These type names are for specific SoCs; other than instantiating
31
+ * them, code using these devices should always handle them via the
32
+ * BCM283x base class, so they have no BCM2836(obj) etc macros.
33
+ */
34
+#define TYPE_BCM2836 "bcm2836"
35
+#define TYPE_BCM2837 "bcm2837"
27
+
36
+
28
+ /* Since we're still using the legacy SD API the card is not plugged
37
typedef struct BCM283XState {
29
+ * into any bus, and we must reset it manually. When omap_mmc is
38
/*< private >*/
30
+ * QOMified this must move into the QOM reset function.
39
DeviceState parent_obj;
31
+ */
40
@@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState {
32
+ device_reset(DEVICE(host->card));
41
BCM2835PeripheralState peripherals;
42
} BCM283XState;
43
44
+typedef struct BCM283XInfo BCM283XInfo;
45
+
46
+typedef struct BCM283XClass {
47
+ DeviceClass parent_class;
48
+ const BCM283XInfo *info;
49
+} BCM283XClass;
50
+
51
+#define BCM283X_CLASS(klass) \
52
+ OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X)
53
+#define BCM283X_GET_CLASS(obj) \
54
+ OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X)
55
+
56
#endif /* BCM2836_H */
57
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/hw/arm/bcm2836.c
60
+++ b/hw/arm/bcm2836.c
61
@@ -XXX,XX +XXX,XX @@
62
/* "QA7" (Pi2) interrupt controller and mailboxes etc. */
63
#define BCM2836_CONTROL_BASE 0x40000000
64
65
+struct BCM283XInfo {
66
+ const char *name;
67
+};
68
+
69
+static const BCM283XInfo bcm283x_socs[] = {
70
+ {
71
+ .name = TYPE_BCM2836,
72
+ },
73
+ {
74
+ .name = TYPE_BCM2837,
75
+ },
76
+};
77
+
78
static void bcm2836_init(Object *obj)
79
{
80
BCM283XState *s = BCM283X(obj);
81
@@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = {
82
DEFINE_PROP_END_OF_LIST()
83
};
84
85
-static void bcm2836_class_init(ObjectClass *oc, void *data)
86
+static void bcm283x_class_init(ObjectClass *oc, void *data)
87
{
88
DeviceClass *dc = DEVICE_CLASS(oc);
89
+ BCM283XClass *bc = BCM283X_CLASS(oc);
90
91
- dc->props = bcm2836_props;
92
+ bc->info = data;
93
dc->realize = bcm2836_realize;
94
+ dc->props = bcm2836_props;
33
}
95
}
34
96
35
static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
97
-static const TypeInfo bcm2836_type_info = {
36
@@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap_mmc_init(hwaddr base,
98
+static const TypeInfo bcm283x_type_info = {
37
s->lines = 1;    /* TODO: needs to be settable per-board */
99
.name = TYPE_BCM283X,
38
s->rev = 1;
100
.parent = TYPE_DEVICE,
39
101
.instance_size = sizeof(BCM283XState),
40
- omap_mmc_reset(s);
102
.instance_init = bcm2836_init,
41
-
103
- .class_init = bcm2836_class_init,
42
memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", 0x800);
104
+ .class_size = sizeof(BCM283XClass),
43
memory_region_add_subregion(sysmem, base, &s->iomem);
105
+ .abstract = true,
44
106
};
45
@@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap_mmc_init(hwaddr base,
107
46
exit(1);
108
static void bcm2836_register_types(void)
47
}
109
{
48
110
- type_register_static(&bcm2836_type_info);
49
+ omap_mmc_reset(s);
111
+ int i;
50
+
112
+
51
return s;
113
+ type_register_static(&bcm283x_type_info);
114
+ for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) {
115
+ TypeInfo ti = {
116
+ .name = bcm283x_socs[i].name,
117
+ .parent = TYPE_BCM283X,
118
+ .class_init = bcm283x_class_init,
119
+ .class_data = (void *) &bcm283x_socs[i],
120
+ };
121
+ type_register(&ti);
122
+ }
52
}
123
}
53
124
54
@@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,
125
type_init(bcm2836_register_types)
55
s->lines = 4;
126
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
56
s->rev = 2;
127
index XXXXXXX..XXXXXXX 100644
57
128
--- a/hw/arm/raspi.c
58
- omap_mmc_reset(s);
129
+++ b/hw/arm/raspi.c
59
-
130
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
60
memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc",
131
BusState *bus;
61
omap_l4_region_size(ta, 0));
132
DeviceState *carddev;
62
omap_l4_attach(ta, 0, &s->iomem);
133
63
@@ -XXX,XX +XXX,XX @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,
134
- object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X);
64
s->cdet = qemu_allocate_irq(omap_mmc_cover_cb, s, 0);
135
+ object_initialize(&s->soc, sizeof(s->soc),
65
sd_set_cb(s->card, NULL, s->cdet);
136
+ version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
66
137
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
67
+ omap_mmc_reset(s);
138
&error_abort);
68
+
69
return s;
70
}
71
139
72
--
140
--
73
2.7.4
141
2.16.2
74
142
75
143
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
The BCM2837 sets the Aff1 field of the MPIDR affinity values for the
2
CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it
3
is required for Linux to boot.
2
4
3
Now both inherited classes appear as DEVICE_CATEGORY_STORAGE.
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20180313153458.26822-8-peter.maydell@linaro.org
9
---
10
hw/arm/bcm2836.c | 11 +++++++----
11
1 file changed, 7 insertions(+), 4 deletions(-)
4
12
5
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
6
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
7
Message-id: 20180115182436.2066-5-f4bug@amsat.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
hw/sd/sdhci.c | 18 +++++++++++++-----
11
1 file changed, 13 insertions(+), 5 deletions(-)
12
13
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/sd/sdhci.c
15
--- a/hw/arm/bcm2836.c
16
+++ b/hw/sd/sdhci.c
16
+++ b/hw/arm/bcm2836.c
17
@@ -XXX,XX +XXX,XX @@ const VMStateDescription sdhci_vmstate = {
17
@@ -XXX,XX +XXX,XX @@
18
19
struct BCM283XInfo {
20
const char *name;
21
+ int clusterid;
22
};
23
24
static const BCM283XInfo bcm283x_socs[] = {
25
{
26
.name = TYPE_BCM2836,
27
+ .clusterid = 0xf,
28
},
29
{
30
.name = TYPE_BCM2837,
31
+ .clusterid = 0x0,
18
},
32
},
19
};
33
};
20
34
21
+static void sdhci_common_class_init(ObjectClass *klass, void *data)
35
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
22
+{
36
static void bcm2836_realize(DeviceState *dev, Error **errp)
23
+ DeviceClass *dc = DEVICE_CLASS(klass);
24
+
25
+ set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
26
+ dc->vmsd = &sdhci_vmstate;
27
+ dc->reset = sdhci_poweron_reset;
28
+}
29
+
30
/* --- qdev PCI --- */
31
32
static Property sdhci_pci_properties[] = {
33
@@ -XXX,XX +XXX,XX @@ static void sdhci_pci_class_init(ObjectClass *klass, void *data)
34
k->vendor_id = PCI_VENDOR_ID_REDHAT;
35
k->device_id = PCI_DEVICE_ID_REDHAT_SDHCI;
36
k->class_id = PCI_CLASS_SYSTEM_SDHCI;
37
- set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
38
- dc->vmsd = &sdhci_vmstate;
39
dc->props = sdhci_pci_properties;
40
- dc->reset = sdhci_poweron_reset;
41
+
42
+ sdhci_common_class_init(klass, data);
43
}
44
45
static const TypeInfo sdhci_pci_info = {
46
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
47
{
37
{
48
DeviceClass *dc = DEVICE_CLASS(klass);
38
BCM283XState *s = BCM283X(dev);
49
39
+ BCM283XClass *bc = BCM283X_GET_CLASS(dev);
50
- dc->vmsd = &sdhci_vmstate;
40
+ const BCM283XInfo *info = bc->info;
51
dc->props = sdhci_sysbus_properties;
41
Object *obj;
52
dc->realize = sdhci_sysbus_realize;
42
Error *err = NULL;
53
- dc->reset = sdhci_poweron_reset;
43
int n;
54
+
44
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
55
+ sdhci_common_class_init(klass, data);
45
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
56
}
46
57
47
for (n = 0; n < BCM283X_NCPUS; n++) {
58
static const TypeInfo sdhci_sysbus_info = {
48
- /* Mirror bcm2836, which has clusterid set to 0xf
49
- * TODO: this should be converted to a property of ARM_CPU
50
- */
51
- s->cpus[n].mp_affinity = 0xF00 | n;
52
+ /* TODO: this should be converted to a property of ARM_CPU */
53
+ s->cpus[n].mp_affinity = (info->clusterid << 8) | n;
54
55
/* set periphbase/CBAR value for CPU-local registers */
56
object_property_set_int(OBJECT(&s->cpus[n]),
59
--
57
--
60
2.7.4
58
2.16.2
61
59
62
60
diff view generated by jsdifflib
1
Instead of ignoring the response from address_space_ld*()
1
Now we have separate types for BCM2386 and BCM2387, we might as well
2
(indicating an attempt to read a page table descriptor from
2
just hard-code the CPU type they use rather than having it passed
3
an invalid physical address), use it to report the failure
3
through as an object property. This then lets us put the initialization
4
correctly.
4
of the CPU object in init rather than realize.
5
5
6
Since this is another couple of locations where we need to
6
Note that this change means that it's no longer possible on
7
decide the value of the ARMMMUFaultInfo ea bit based on a
7
the command line to use -cpu to ask for a different kind of
8
MemTxResult, we factor out that operation into a helper
8
CPU than the SoC supports. This was never a supported thing to
9
function.
9
do anyway; we were just not sanity-checking the command line.
10
11
This does require us to only build the bcm2837 object on
12
TARGET_AARCH64 configs, since otherwise it won't instantiate
13
due to the missing cortex-a53 device and "make check" will fail.
10
14
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Message-id: 20180313153458.26822-9-peter.maydell@linaro.org
12
---
19
---
13
target/arm/internals.h | 10 ++++++++++
20
hw/arm/bcm2836.c | 24 +++++++++++++++---------
14
target/arm/helper.c | 39 ++++++++++++++++++++++++++++++++++-----
21
hw/arm/raspi.c | 2 --
15
target/arm/op_helper.c | 7 +------
22
2 files changed, 15 insertions(+), 11 deletions(-)
16
3 files changed, 45 insertions(+), 11 deletions(-)
17
23
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
24
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
19
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/internals.h
26
--- a/hw/arm/bcm2836.c
21
+++ b/target/arm/internals.h
27
+++ b/hw/arm/bcm2836.c
22
@@ -XXX,XX +XXX,XX @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *fi)
28
@@ -XXX,XX +XXX,XX @@
23
return fsc;
29
30
struct BCM283XInfo {
31
const char *name;
32
+ const char *cpu_type;
33
int clusterid;
34
};
35
36
static const BCM283XInfo bcm283x_socs[] = {
37
{
38
.name = TYPE_BCM2836,
39
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"),
40
.clusterid = 0xf,
41
},
42
+#ifdef TARGET_AARCH64
43
{
44
.name = TYPE_BCM2837,
45
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"),
46
.clusterid = 0x0,
47
},
48
+#endif
49
};
50
51
static void bcm2836_init(Object *obj)
52
{
53
BCM283XState *s = BCM283X(obj);
54
+ BCM283XClass *bc = BCM283X_GET_CLASS(obj);
55
+ const BCM283XInfo *info = bc->info;
56
+ int n;
57
+
58
+ for (n = 0; n < BCM283X_NCPUS; n++) {
59
+ object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
60
+ info->cpu_type);
61
+ object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
62
+ &error_abort);
63
+ }
64
65
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
66
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
67
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
68
69
/* common peripherals from bcm2835 */
70
71
- obj = OBJECT(dev);
72
- for (n = 0; n < BCM283X_NCPUS; n++) {
73
- object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
74
- s->cpu_type);
75
- object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
76
- &error_abort);
77
- }
78
-
79
obj = object_property_get_link(OBJECT(dev), "ram", &err);
80
if (obj == NULL) {
81
error_setg(errp, "%s: required ram link not found: %s",
82
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
24
}
83
}
25
84
26
+static inline bool arm_extabort_type(MemTxResult result)
85
static Property bcm2836_props[] = {
27
+{
86
- DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type),
28
+ /* The EA bit in syndromes and fault status registers is an
87
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
29
+ * IMPDEF classification of external aborts. ARM implementations
88
BCM283X_NCPUS),
30
+ * usually use this to indicate AXI bus Decode error (0) or
89
DEFINE_PROP_END_OF_LIST()
31
+ * Slave error (1); in QEMU we follow that.
90
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
32
+ */
33
+ return result != MEMTX_DECODE_ERROR;
34
+}
35
+
36
/* Do a page table walk and add page to TLB if possible */
37
bool arm_tlb_fill(CPUState *cpu, vaddr address,
38
MMUAccessType access_type, int mmu_idx,
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
40
index XXXXXXX..XXXXXXX 100644
91
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
92
--- a/hw/arm/raspi.c
42
+++ b/target/arm/helper.c
93
+++ b/hw/arm/raspi.c
43
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
94
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
44
ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa,
95
/* Setup the SOC */
45
&txattrs, &s2prot, &s2size, fi, NULL);
96
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
46
if (ret) {
97
&error_abort);
47
+ assert(fi->type != ARMFault_None);
98
- object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
48
fi->s2addr = addr;
99
- &error_abort);
49
fi->stage2 = true;
100
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
50
fi->s1ptw = true;
101
&error_abort);
51
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,
102
int board_rev = version == 3 ? 0xa02082 : 0xa21041;
52
ARMCPU *cpu = ARM_CPU(cs);
53
CPUARMState *env = &cpu->env;
54
MemTxAttrs attrs = {};
55
+ MemTxResult result = MEMTX_OK;
56
AddressSpace *as;
57
+ uint32_t data;
58
59
attrs.secure = is_secure;
60
as = arm_addressspace(cs, attrs);
61
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,
62
return 0;
63
}
64
if (regime_translation_big_endian(env, mmu_idx)) {
65
- return address_space_ldl_be(as, addr, attrs, NULL);
66
+ data = address_space_ldl_be(as, addr, attrs, &result);
67
} else {
68
- return address_space_ldl_le(as, addr, attrs, NULL);
69
+ data = address_space_ldl_le(as, addr, attrs, &result);
70
}
71
+ if (result == MEMTX_OK) {
72
+ return data;
73
+ }
74
+ fi->type = ARMFault_SyncExternalOnWalk;
75
+ fi->ea = arm_extabort_type(result);
76
+ return 0;
77
}
78
79
static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
80
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
81
ARMCPU *cpu = ARM_CPU(cs);
82
CPUARMState *env = &cpu->env;
83
MemTxAttrs attrs = {};
84
+ MemTxResult result = MEMTX_OK;
85
AddressSpace *as;
86
+ uint32_t data;
87
88
attrs.secure = is_secure;
89
as = arm_addressspace(cs, attrs);
90
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
91
return 0;
92
}
93
if (regime_translation_big_endian(env, mmu_idx)) {
94
- return address_space_ldq_be(as, addr, attrs, NULL);
95
+ data = address_space_ldq_be(as, addr, attrs, &result);
96
} else {
97
- return address_space_ldq_le(as, addr, attrs, NULL);
98
+ data = address_space_ldq_le(as, addr, attrs, &result);
99
+ }
100
+ if (result == MEMTX_OK) {
101
+ return data;
102
}
103
+ fi->type = ARMFault_SyncExternalOnWalk;
104
+ fi->ea = arm_extabort_type(result);
105
+ return 0;
106
}
107
108
static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
109
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
110
}
111
desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx),
112
mmu_idx, fi);
113
+ if (fi->type != ARMFault_None) {
114
+ goto do_fault;
115
+ }
116
type = (desc & 3);
117
domain = (desc >> 5) & 0x0f;
118
if (regime_el(env, mmu_idx) == 1) {
119
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
120
}
121
desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx),
122
mmu_idx, fi);
123
+ if (fi->type != ARMFault_None) {
124
+ goto do_fault;
125
+ }
126
switch (desc & 3) {
127
case 0: /* Page translation fault. */
128
fi->type = ARMFault_Translation;
129
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
130
}
131
desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx),
132
mmu_idx, fi);
133
+ if (fi->type != ARMFault_None) {
134
+ goto do_fault;
135
+ }
136
type = (desc & 3);
137
if (type == 0 || (type == 3 && !arm_feature(env, ARM_FEATURE_PXN))) {
138
/* Section translation fault, or attempt to use the encoding
139
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
140
table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc);
141
desc = arm_ldl_ptw(cs, table, regime_is_secure(env, mmu_idx),
142
mmu_idx, fi);
143
+ if (fi->type != ARMFault_None) {
144
+ goto do_fault;
145
+ }
146
ap = ((desc >> 4) & 3) | ((desc >> 7) & 4);
147
switch (desc & 3) {
148
case 0: /* Page translation fault. */
149
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
150
descaddr &= ~7ULL;
151
nstable = extract32(tableattrs, 4, 1);
152
descriptor = arm_ldq_ptw(cs, descaddr, !nstable, mmu_idx, fi);
153
- if (fi->s1ptw) {
154
+ if (fi->type != ARMFault_None) {
155
goto do_fault;
156
}
157
158
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
159
index XXXXXXX..XXXXXXX 100644
160
--- a/target/arm/op_helper.c
161
+++ b/target/arm/op_helper.c
162
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
163
/* now we have a real cpu fault */
164
cpu_restore_state(cs, retaddr);
165
166
- /* The EA bit in syndromes and fault status registers is an
167
- * IMPDEF classification of external aborts. ARM implementations
168
- * usually use this to indicate AXI bus Decode error (0) or
169
- * Slave error (1); in QEMU we follow that.
170
- */
171
- fi.ea = (response != MEMTX_DECODE_ERROR);
172
+ fi.ea = arm_extabort_type(response);
173
fi.type = ARMFault_SyncExternal;
174
deliver_fault(cpu, addr, access_type, mmu_idx, &fi);
175
}
176
--
103
--
177
2.7.4
104
2.16.2
178
105
179
106
diff view generated by jsdifflib
Deleted patch
1
Since pl181 is still using the legacy SD card API, the SD
2
card created by sd_init() is not plugged into any bus. This
3
means that the controller has to reset it manually.
4
1
5
Failing to do this mostly didn't affect the guest since the
6
guest typically does a programmed SD card reset as part of
7
its SD controller driver initialization, but meant that
8
migration failed because it's only in sd_reset() that we
9
set up the wpgrps_size field.
10
11
Cc: qemu-stable@nongnu.org
12
Fixes: https://bugs.launchpad.net/qemu/+bug/1739378
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-id: 1515506513-31961-2-git-send-email-peter.maydell@linaro.org
17
---
18
hw/sd/pl181.c | 4 ++++
19
1 file changed, 4 insertions(+)
20
21
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/sd/pl181.c
24
+++ b/hw/sd/pl181.c
25
@@ -XXX,XX +XXX,XX @@ static void pl181_reset(DeviceState *d)
26
27
/* We can assume our GPIO outputs have been wired up now */
28
sd_set_cb(s->card, s->cardstatus[0], s->cardstatus[1]);
29
+ /* Since we're still using the legacy SD API the card is not plugged
30
+ * into any bus, and we must reset it manually.
31
+ */
32
+ device_reset(DEVICE(s->card));
33
}
34
35
static void pl181_init(Object *obj)
36
--
37
2.7.4
38
39
diff view generated by jsdifflib
Deleted patch
1
Since ssi-sd is still using the legacy SD card API, the SD
2
card created by sd_init() is not plugged into any bus. This
3
means that the controller has to reset it manually.
4
1
5
Failing to do this mostly didn't affect the guest since the
6
guest typically does a programmed SD card reset as part of
7
its SD controller driver initialization, but meant that
8
migration failed because it's only in sd_reset() that we
9
set up the wpgrps_size field.
10
11
In the case of sd-ssi, we have to implement an entire
12
reset function since there wasn't one previously, and
13
that requires a QOM cast macro that got omitted when this
14
device was QOMified.
15
16
Cc: qemu-stable@nongnu.org
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Message-id: 1515506513-31961-4-git-send-email-peter.maydell@linaro.org
21
---
22
hw/sd/ssi-sd.c | 25 +++++++++++++++++++++++--
23
1 file changed, 23 insertions(+), 2 deletions(-)
24
25
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/sd/ssi-sd.c
28
+++ b/hw/sd/ssi-sd.c
29
@@ -XXX,XX +XXX,XX @@ typedef struct {
30
SDState *sd;
31
} ssi_sd_state;
32
33
+#define TYPE_SSI_SD "ssi-sd"
34
+#define SSI_SD(obj) OBJECT_CHECK(ssi_sd_state, (obj), TYPE_SSI_SD)
35
+
36
/* State word bits. */
37
#define SSI_SDR_LOCKED 0x0001
38
#define SSI_SDR_WP_ERASE 0x0002
39
@@ -XXX,XX +XXX,XX @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
40
ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
41
DriveInfo *dinfo;
42
43
- s->mode = SSI_SD_CMD;
44
/* FIXME use a qdev drive property instead of drive_get_next() */
45
dinfo = drive_get_next(IF_SD);
46
s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true);
47
@@ -XXX,XX +XXX,XX @@ static void ssi_sd_realize(SSISlave *d, Error **errp)
48
}
49
}
50
51
+static void ssi_sd_reset(DeviceState *dev)
52
+{
53
+ ssi_sd_state *s = SSI_SD(dev);
54
+
55
+ s->mode = SSI_SD_CMD;
56
+ s->cmd = 0;
57
+ memset(s->cmdarg, 0, sizeof(s->cmdarg));
58
+ memset(s->response, 0, sizeof(s->response));
59
+ s->arglen = 0;
60
+ s->response_pos = 0;
61
+ s->stopping = 0;
62
+
63
+ /* Since we're still using the legacy SD API the card is not plugged
64
+ * into any bus, and we must reset it manually.
65
+ */
66
+ device_reset(DEVICE(s->sd));
67
+}
68
+
69
static void ssi_sd_class_init(ObjectClass *klass, void *data)
70
{
71
DeviceClass *dc = DEVICE_CLASS(klass);
72
@@ -XXX,XX +XXX,XX @@ static void ssi_sd_class_init(ObjectClass *klass, void *data)
73
k->transfer = ssi_sd_transfer;
74
k->cs_polarity = SSI_CS_LOW;
75
dc->vmsd = &vmstate_ssi_sd;
76
+ dc->reset = ssi_sd_reset;
77
}
78
79
static const TypeInfo ssi_sd_info = {
80
- .name = "ssi-sd",
81
+ .name = TYPE_SSI_SD,
82
.parent = TYPE_SSI_SLAVE,
83
.instance_size = sizeof(ssi_sd_state),
84
.class_init = ssi_sd_class_init,
85
--
86
2.7.4
87
88
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20180110063337.21538-2-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/translate-a64.c | 44 ++++++++++++++++++++++++++++----------------
9
1 file changed, 28 insertions(+), 16 deletions(-)
10
11
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/translate-a64.c
14
+++ b/target/arm/translate-a64.c
15
@@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn)
16
}
17
}
18
19
+/* The imm8 encodes the sign bit, enough bits to represent an exponent in
20
+ * the range 01....1xx to 10....0xx, and the most significant 4 bits of
21
+ * the mantissa; see VFPExpandImm() in the v8 ARM ARM.
22
+ */
23
+static uint64_t vfp_expand_imm(int size, uint8_t imm8)
24
+{
25
+ uint64_t imm;
26
+
27
+ switch (size) {
28
+ case MO_64:
29
+ imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
30
+ (extract32(imm8, 6, 1) ? 0x3fc0 : 0x4000) |
31
+ extract32(imm8, 0, 6);
32
+ imm <<= 48;
33
+ break;
34
+ case MO_32:
35
+ imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
36
+ (extract32(imm8, 6, 1) ? 0x3e00 : 0x4000) |
37
+ (extract32(imm8, 0, 6) << 3);
38
+ imm <<= 16;
39
+ break;
40
+ default:
41
+ g_assert_not_reached();
42
+ }
43
+ return imm;
44
+}
45
+
46
/* Floating point immediate
47
* 31 30 29 28 24 23 22 21 20 13 12 10 9 5 4 0
48
* +---+---+---+-----------+------+---+------------+-------+------+------+
49
@@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn)
50
return;
51
}
52
53
- /* The imm8 encodes the sign bit, enough bits to represent
54
- * an exponent in the range 01....1xx to 10....0xx,
55
- * and the most significant 4 bits of the mantissa; see
56
- * VFPExpandImm() in the v8 ARM ARM.
57
- */
58
- if (is_double) {
59
- imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
60
- (extract32(imm8, 6, 1) ? 0x3fc0 : 0x4000) |
61
- extract32(imm8, 0, 6);
62
- imm <<= 48;
63
- } else {
64
- imm = (extract32(imm8, 7, 1) ? 0x8000 : 0) |
65
- (extract32(imm8, 6, 1) ? 0x3e00 : 0x4000) |
66
- (extract32(imm8, 0, 6) << 3);
67
- imm <<= 16;
68
- }
69
+ imm = vfp_expand_imm(MO_32 + is_double, imm8);
70
71
tcg_res = tcg_const_i64(imm);
72
write_fp_dreg(s, rd, tcg_res);
73
--
74
2.7.4
75
76
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180115182436.2066-2-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/sd/sdhci-internal.h | 4 ----
9
include/hw/sd/sdhci.h | 7 ++++++-
10
hw/sd/sdhci.c | 1 +
11
3 files changed, 7 insertions(+), 5 deletions(-)
12
13
diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/sd/sdhci-internal.h
16
+++ b/hw/sd/sdhci-internal.h
17
@@ -XXX,XX +XXX,XX @@
18
#ifndef SDHCI_INTERNAL_H
19
#define SDHCI_INTERNAL_H
20
21
-#include "hw/sd/sdhci.h"
22
-
23
/* R/W SDMA System Address register 0x0 */
24
#define SDHC_SYSAD 0x00
25
26
@@ -XXX,XX +XXX,XX @@ enum {
27
sdhc_gap_write = 2 /* SDHC stopped at block gap during write operation */
28
};
29
30
-extern const VMStateDescription sdhci_vmstate;
31
-
32
#endif
33
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/include/hw/sd/sdhci.h
36
+++ b/include/hw/sd/sdhci.h
37
@@ -XXX,XX +XXX,XX @@
38
#define SDHCI_H
39
40
#include "qemu-common.h"
41
-#include "hw/block/block.h"
42
#include "hw/pci/pci.h"
43
#include "hw/sysbus.h"
44
#include "hw/sd/sd.h"
45
46
/* SD/MMC host controller state */
47
typedef struct SDHCIState {
48
+ /*< private >*/
49
union {
50
PCIDevice pcidev;
51
SysBusDevice busdev;
52
};
53
+
54
+ /*< public >*/
55
SDBus sdbus;
56
MemoryRegion iomem;
57
58
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
59
qemu_irq ro_cb;
60
qemu_irq irq;
61
62
+ /* Registers cleared on reset */
63
uint32_t sdmasysad; /* SDMA System Address register */
64
uint16_t blksize; /* Host DMA Buff Boundary and Transfer BlkSize Reg */
65
uint16_t blkcnt; /* Blocks count for current transfer */
66
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
67
uint16_t acmd12errsts; /* Auto CMD12 error status register */
68
uint64_t admasysaddr; /* ADMA System Address Register */
69
70
+ /* Read-only registers */
71
uint32_t capareg; /* Capabilities Register */
72
uint32_t maxcurr; /* Maximum Current Capabilities Register */
73
+
74
uint8_t *fifo_buffer; /* SD host i/o FIFO buffer */
75
uint32_t buf_maxsz;
76
uint16_t data_count; /* current element in FIFO buffer */
77
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/sd/sdhci.c
80
+++ b/hw/sd/sdhci.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "sysemu/dma.h"
83
#include "qemu/timer.h"
84
#include "qemu/bitops.h"
85
+#include "hw/sd/sdhci.h"
86
#include "sdhci-internal.h"
87
#include "qemu/log.h"
88
89
--
90
2.7.4
91
92
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180115182436.2066-3-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
include/hw/sd/sdhci.h | 2 --
9
hw/sd/sdhci.c | 2 --
10
2 files changed, 4 deletions(-)
11
12
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/sd/sdhci.h
15
+++ b/include/hw/sd/sdhci.h
16
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
17
18
QEMUTimer *insert_timer; /* timer for 'changing' sd card. */
19
QEMUTimer *transfer_timer;
20
- qemu_irq eject_cb;
21
- qemu_irq ro_cb;
22
qemu_irq irq;
23
24
/* Registers cleared on reset */
25
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/sd/sdhci.c
28
+++ b/hw/sd/sdhci.c
29
@@ -XXX,XX +XXX,XX @@ static void sdhci_uninitfn(SDHCIState *s)
30
timer_free(s->insert_timer);
31
timer_del(s->transfer_timer);
32
timer_free(s->transfer_timer);
33
- qemu_free_irq(s->eject_cb);
34
- qemu_free_irq(s->ro_cb);
35
36
g_free(s->fifo_buffer);
37
s->fifo_buffer = NULL;
38
--
39
2.7.4
40
41
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Add common/sysbus/pci/sdbus comments to have clearer code blocks separation.
4
5
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Message-id: 20180115182436.2066-4-f4bug@amsat.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
include/hw/sd/sdhci.h | 4 +++-
11
hw/sd/sdhci.c | 25 +++++++++++++++++--------
12
2 files changed, 20 insertions(+), 9 deletions(-)
13
14
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/sd/sdhci.h
17
+++ b/include/hw/sd/sdhci.h
18
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
19
uint32_t buf_maxsz;
20
uint16_t data_count; /* current element in FIFO buffer */
21
uint8_t stopped_state;/* Current SDHC state */
22
- bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */
23
bool pending_insert_state;
24
/* Buffer Data Port Register - virtual access point to R and W buffers */
25
/* Software Reset Register - always reads as 0 */
26
/* Force Event Auto CMD12 Error Interrupt Reg - write only */
27
/* Force Event Error Interrupt Register- write only */
28
/* RO Host Controller Version Register always reads as 0x2401 */
29
+
30
+ /* Configurable properties */
31
+ bool pending_insert_quirk; /* Quirk for Raspberry Pi card insert int */
32
} SDHCIState;
33
34
#define TYPE_PCI_SDHCI "sdhci-pci"
35
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/sd/sdhci.c
38
+++ b/hw/sd/sdhci.c
39
@@ -XXX,XX +XXX,XX @@
40
*/
41
42
#include "qemu/osdep.h"
43
+#include "qapi/error.h"
44
#include "hw/hw.h"
45
#include "sysemu/block-backend.h"
46
#include "sysemu/blockdev.h"
47
@@ -XXX,XX +XXX,XX @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s)
48
}
49
}
50
51
+/* --- qdev common --- */
52
+
53
+#define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \
54
+ /* Capabilities registers provide information on supported features
55
+ * of this specific host controller implementation */ \
56
+ DEFINE_PROP_UINT32("capareg", _state, capareg, SDHC_CAPAB_REG_DEFAULT), \
57
+ DEFINE_PROP_UINT32("maxcurr", _state, maxcurr, 0)
58
+
59
static void sdhci_initfn(SDHCIState *s)
60
{
61
qbus_create_inplace(&s->sdbus, sizeof(s->sdbus),
62
@@ -XXX,XX +XXX,XX @@ const VMStateDescription sdhci_vmstate = {
63
},
64
};
65
66
-/* Capabilities registers provide information on supported features of this
67
- * specific host controller implementation */
68
+/* --- qdev PCI --- */
69
+
70
static Property sdhci_pci_properties[] = {
71
- DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
72
- SDHC_CAPAB_REG_DEFAULT),
73
- DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
74
+ DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState),
75
DEFINE_PROP_END_OF_LIST(),
76
};
77
78
@@ -XXX,XX +XXX,XX @@ static const TypeInfo sdhci_pci_info = {
79
},
80
};
81
82
+/* --- qdev SysBus --- */
83
+
84
static Property sdhci_sysbus_properties[] = {
85
- DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
86
- SDHC_CAPAB_REG_DEFAULT),
87
- DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
88
+ DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState),
89
DEFINE_PROP_BOOL("pending-insert-quirk", SDHCIState, pending_insert_quirk,
90
false),
91
DEFINE_PROP_END_OF_LIST(),
92
@@ -XXX,XX +XXX,XX @@ static const TypeInfo sdhci_sysbus_info = {
93
.class_init = sdhci_sysbus_class_init,
94
};
95
96
+/* --- qdev bus master --- */
97
+
98
static void sdhci_bus_class_init(ObjectClass *klass, void *data)
99
{
100
SDBusClass *sbc = SD_BUS_CLASS(klass);
101
--
102
2.7.4
103
104
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
The raspi3 has AArch64 CPUs, which means that our smpboot
2
code for keeping the secondary CPUs in a pen needs to have
3
a version for A64 as well as A32. Without this, the
4
secondary CPUs go into an infinite loop of taking undefined
5
instruction exceptions.
2
6
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180115182436.2066-6-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20180313153458.26822-10-peter.maydell@linaro.org
7
---
10
---
8
hw/sd/sdhci.c | 30 +++++++++++++++++++++---------
11
hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++-
9
1 file changed, 21 insertions(+), 9 deletions(-)
12
1 file changed, 40 insertions(+), 1 deletion(-)
10
13
11
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
14
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/sdhci.c
16
--- a/hw/arm/raspi.c
14
+++ b/hw/sd/sdhci.c
17
+++ b/hw/arm/raspi.c
15
@@ -XXX,XX +XXX,XX @@ static void sdhci_uninitfn(SDHCIState *s)
18
@@ -XXX,XX +XXX,XX @@
16
s->fifo_buffer = NULL;
19
#define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
20
#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */
21
#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
22
+#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */
23
24
/* Table of Linux board IDs for different Pi versions */
25
static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
26
@@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
27
info->smp_loader_start);
17
}
28
}
18
29
19
+static void sdhci_common_realize(SDHCIState *s, Error **errp)
30
+static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
20
+{
31
+{
21
+ s->buf_maxsz = sdhci_get_fifolen(s);
32
+ /* Unlike the AArch32 version we don't need to call the board setup hook.
22
+ s->fifo_buffer = g_malloc0(s->buf_maxsz);
33
+ * The mechanism for doing the spin-table is also entirely different.
34
+ * We must have four 64-bit fields at absolute addresses
35
+ * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for
36
+ * our CPUs, and which we must ensure are zero initialized before
37
+ * the primary CPU goes into the kernel. We put these variables inside
38
+ * a rom blob, so that the reset for ROM contents zeroes them for us.
39
+ */
40
+ static const uint32_t smpboot[] = {
41
+ 0xd2801b05, /* mov x5, 0xd8 */
42
+ 0xd53800a6, /* mrs x6, mpidr_el1 */
43
+ 0x924004c6, /* and x6, x6, #0x3 */
44
+ 0xd503205f, /* spin: wfe */
45
+ 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */
46
+ 0xb4ffffc4, /* cbz x4, spin */
47
+ 0xd2800000, /* mov x0, #0x0 */
48
+ 0xd2800001, /* mov x1, #0x0 */
49
+ 0xd2800002, /* mov x2, #0x0 */
50
+ 0xd2800003, /* mov x3, #0x0 */
51
+ 0xd61f0080, /* br x4 */
52
+ };
23
+
53
+
24
+ memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci",
54
+ static const uint64_t spintables[] = {
25
+ SDHC_REGISTERS_MAP_SIZE);
55
+ 0, 0, 0, 0
56
+ };
57
+
58
+ rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot),
59
+ info->smp_loader_start);
60
+ rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables),
61
+ SPINTABLE_ADDR);
26
+}
62
+}
27
+
63
+
28
static bool sdhci_pending_insert_vmstate_needed(void *opaque)
64
static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info)
29
{
65
{
30
SDHCIState *s = opaque;
66
arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR);
31
@@ -XXX,XX +XXX,XX @@ static Property sdhci_pci_properties[] = {
67
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
32
static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
68
/* Pi2 and Pi3 requires SMP setup */
33
{
69
if (version >= 2) {
34
SDHCIState *s = PCI_SDHCI(dev);
70
binfo.smp_loader_start = SMPBOOT_ADDR;
35
+
71
- binfo.write_secondary_boot = write_smpboot;
36
+ sdhci_initfn(s);
72
+ if (version == 2) {
37
+ sdhci_common_realize(s, errp);
73
+ binfo.write_secondary_boot = write_smpboot;
38
+ if (errp && *errp) {
74
+ } else {
39
+ return;
75
+ binfo.write_secondary_boot = write_smpboot64;
40
+ }
76
+ }
41
+
77
binfo.secondary_cpu_reset_hook = reset_secondary;
42
dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */
78
}
43
dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
44
- sdhci_initfn(s);
45
- s->buf_maxsz = sdhci_get_fifolen(s);
46
- s->fifo_buffer = g_malloc0(s->buf_maxsz);
47
s->irq = pci_allocate_irq(dev);
48
- memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci",
49
- SDHC_REGISTERS_MAP_SIZE);
50
pci_register_bar(dev, 0, 0, &s->iomem);
51
}
52
53
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
54
SDHCIState *s = SYSBUS_SDHCI(dev);
55
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
56
57
- s->buf_maxsz = sdhci_get_fifolen(s);
58
- s->fifo_buffer = g_malloc0(s->buf_maxsz);
59
+ sdhci_common_realize(s, errp);
60
+ if (errp && *errp) {
61
+ return;
62
+ }
63
+
64
sysbus_init_irq(sbd, &s->irq);
65
- memory_region_init_io(&s->iomem, OBJECT(s), &sdhci_mmio_ops, s, "sdhci",
66
- SDHC_REGISTERS_MAP_SIZE);
67
sysbus_init_mmio(sbd, &s->iomem);
68
}
69
79
70
--
80
--
71
2.7.4
81
2.16.2
72
82
73
83
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180115182436.2066-8-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/sd/sdhci.c | 7 ++++---
9
1 file changed, 4 insertions(+), 3 deletions(-)
10
11
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/sdhci.c
14
+++ b/hw/sd/sdhci.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
16
ret = (SD_HOST_SPECv2_VERS << 16) | sdhci_slotint(s);
17
break;
18
default:
19
- ERRPRINT("bad %ub read: addr[0x%04x]\n", size, (int)offset);
20
+ qemu_log_mask(LOG_UNIMP, "SDHC rd_%ub @0x%02" HWADDR_PRIx " "
21
+ "not implemented\n", size, offset);
22
break;
23
}
24
25
@@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
26
sdhci_update_irq(s);
27
break;
28
default:
29
- ERRPRINT("bad %ub write offset: addr[0x%04x] <- %u(0x%x)\n",
30
- size, (int)offset, value >> shift, value >> shift);
31
+ qemu_log_mask(LOG_UNIMP, "SDHC wr_%ub @0x%02" HWADDR_PRIx " <- 0x%08x "
32
+ "not implemented\n", size, offset, value >> shift);
33
break;
34
}
35
DPRINT_L2("write %ub: addr[0x%04x] <- %u(0x%x)\n",
36
--
37
2.7.4
38
39
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180115182436.2066-10-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/sd/sdhci-internal.h | 1 +
9
hw/sd/sdhci.c | 3 +--
10
2 files changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/sd/sdhci-internal.h
15
+++ b/hw/sd/sdhci-internal.h
16
@@ -XXX,XX +XXX,XX @@
17
#define SDHC_TRNS_ACMD12 0x0004
18
#define SDHC_TRNS_READ 0x0010
19
#define SDHC_TRNS_MULTI 0x0020
20
+#define SDHC_TRNMOD_MASK 0x0037
21
22
/* R/W Command Register 0x0 */
23
#define SDHC_CMDREG 0x0E
24
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/sd/sdhci.c
27
+++ b/hw/sd/sdhci.c
28
@@ -XXX,XX +XXX,XX @@
29
(SDHC_CAPAB_BASECLKFREQ << 8) | (SDHC_CAPAB_TOUNIT << 7) | \
30
(SDHC_CAPAB_TOCLKFREQ))
31
32
-#define MASK_TRNMOD 0x0037
33
#define MASKED_WRITE(reg, mask, val) (reg = (reg & (mask)) | (val))
34
35
static uint8_t sdhci_slotint(SDHCIState *s)
36
@@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
37
if (!(s->capareg & SDHC_CAN_DO_DMA)) {
38
value &= ~SDHC_TRNS_DMA;
39
}
40
- MASKED_WRITE(s->trnmod, mask, value & MASK_TRNMOD);
41
+ MASKED_WRITE(s->trnmod, mask, value & SDHC_TRNMOD_MASK);
42
MASKED_WRITE(s->cmdreg, mask >> 16, value >> 16);
43
44
/* Writing to the upper byte of CMDREG triggers SD command generation */
45
--
46
2.7.4
47
48
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
5
Message-id: 20180115182436.2066-11-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/sd/sdhci-internal.h | 2 +-
9
hw/sd/sdhci.c | 2 +-
10
2 files changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/sd/sdhci-internal.h
15
+++ b/hw/sd/sdhci-internal.h
16
@@ -XXX,XX +XXX,XX @@
17
#define SDHC_ACMD12ERRSTS 0x3C
18
19
/* HWInit Capabilities Register 0x05E80080 */
20
-#define SDHC_CAPAREG 0x40
21
+#define SDHC_CAPAB 0x40
22
#define SDHC_CAN_DO_DMA 0x00400000
23
#define SDHC_CAN_DO_ADMA2 0x00080000
24
#define SDHC_CAN_DO_ADMA1 0x00100000
25
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/sd/sdhci.c
28
+++ b/hw/sd/sdhci.c
29
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
30
case SDHC_ACMD12ERRSTS:
31
ret = s->acmd12errsts;
32
break;
33
- case SDHC_CAPAREG:
34
+ case SDHC_CAPAB:
35
ret = s->capareg;
36
break;
37
case SDHC_MAXCURR:
38
--
39
2.7.4
40
41
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
running qtests:
4
5
$ make check-qtest-arm
6
GTESTER check-qtest-arm
7
SDHC rd_4b @0x44 not implemented
8
SDHC wr_4b @0x40 <- 0x89abcdef not implemented
9
SDHC wr_4b @0x44 <- 0x01234567 not implemented
10
11
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
13
Message-id: 20180115182436.2066-12-f4bug@amsat.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
include/hw/sd/sdhci.h | 4 ++--
17
hw/sd/sdhci.c | 23 +++++++++++++++++++----
18
2 files changed, 21 insertions(+), 6 deletions(-)
19
20
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/sd/sdhci.h
23
+++ b/include/hw/sd/sdhci.h
24
@@ -XXX,XX +XXX,XX @@ typedef struct SDHCIState {
25
uint64_t admasysaddr; /* ADMA System Address Register */
26
27
/* Read-only registers */
28
- uint32_t capareg; /* Capabilities Register */
29
- uint32_t maxcurr; /* Maximum Current Capabilities Register */
30
+ uint64_t capareg; /* Capabilities Register */
31
+ uint64_t maxcurr; /* Maximum Current Capabilities Register */
32
33
uint8_t *fifo_buffer; /* SD host i/o FIFO buffer */
34
uint32_t buf_maxsz;
35
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/sd/sdhci.c
38
+++ b/hw/sd/sdhci.c
39
@@ -XXX,XX +XXX,XX @@ static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
40
ret = s->acmd12errsts;
41
break;
42
case SDHC_CAPAB:
43
- ret = s->capareg;
44
+ ret = (uint32_t)s->capareg;
45
+ break;
46
+ case SDHC_CAPAB + 4:
47
+ ret = (uint32_t)(s->capareg >> 32);
48
break;
49
case SDHC_MAXCURR:
50
- ret = s->maxcurr;
51
+ ret = (uint32_t)s->maxcurr;
52
+ break;
53
+ case SDHC_MAXCURR + 4:
54
+ ret = (uint32_t)(s->maxcurr >> 32);
55
break;
56
case SDHC_ADMAERR:
57
ret = s->admaerr;
58
@@ -XXX,XX +XXX,XX @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
59
}
60
sdhci_update_irq(s);
61
break;
62
+
63
+ case SDHC_CAPAB:
64
+ case SDHC_CAPAB + 4:
65
+ case SDHC_MAXCURR:
66
+ case SDHC_MAXCURR + 4:
67
+ qemu_log_mask(LOG_GUEST_ERROR, "SDHC wr_%ub @0x%02" HWADDR_PRIx
68
+ " <- 0x%08x read-only\n", size, offset, value >> shift);
69
+ break;
70
+
71
default:
72
qemu_log_mask(LOG_UNIMP, "SDHC wr_%ub @0x%02" HWADDR_PRIx " <- 0x%08x "
73
"not implemented\n", size, offset, value >> shift);
74
@@ -XXX,XX +XXX,XX @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s)
75
#define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \
76
/* Capabilities registers provide information on supported features
77
* of this specific host controller implementation */ \
78
- DEFINE_PROP_UINT32("capareg", _state, capareg, SDHC_CAPAB_REG_DEFAULT), \
79
- DEFINE_PROP_UINT32("maxcurr", _state, maxcurr, 0)
80
+ DEFINE_PROP_UINT64("capareg", _state, capareg, SDHC_CAPAB_REG_DEFAULT), \
81
+ DEFINE_PROP_UINT64("maxcurr", _state, maxcurr, 0)
82
83
static void sdhci_initfn(SDHCIState *s)
84
{
85
--
86
2.7.4
87
88
diff view generated by jsdifflib