2007-09-17 01:08:06 +04:00
|
|
|
/*
|
2006-09-23 21:40:58 +04:00
|
|
|
* Arm PrimeCell PL080/PL081 DMA controller
|
2006-04-09 05:32:52 +04:00
|
|
|
*
|
|
|
|
* Copyright (c) 2006 CodeSourcery.
|
|
|
|
* Written by Paul Brook
|
|
|
|
*
|
2011-06-26 06:21:35 +04:00
|
|
|
* This code is licensed under the GPL.
|
2006-04-09 05:32:52 +04:00
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:05 +03:00
|
|
|
#include "qemu/osdep.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/sysbus.h"
|
2019-08-12 08:23:45 +03:00
|
|
|
#include "migration/vmstate.h"
|
2013-11-15 17:46:38 +04:00
|
|
|
#include "exec/address-spaces.h"
|
2015-12-15 15:16:16 +03:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2018-08-20 13:24:33 +03:00
|
|
|
#include "hw/dma/pl080.h"
|
2019-08-12 08:23:48 +03:00
|
|
|
#include "hw/hw.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2018-08-20 13:24:33 +03:00
|
|
|
#include "qapi/error.h"
|
2006-04-09 05:32:52 +04:00
|
|
|
|
|
|
|
#define PL080_CONF_E 0x1
|
|
|
|
#define PL080_CONF_M1 0x2
|
|
|
|
#define PL080_CONF_M2 0x4
|
|
|
|
|
|
|
|
#define PL080_CCONF_H 0x40000
|
|
|
|
#define PL080_CCONF_A 0x20000
|
|
|
|
#define PL080_CCONF_L 0x10000
|
|
|
|
#define PL080_CCONF_ITC 0x08000
|
|
|
|
#define PL080_CCONF_IE 0x04000
|
|
|
|
#define PL080_CCONF_E 0x00001
|
|
|
|
|
|
|
|
#define PL080_CCTRL_I 0x80000000
|
|
|
|
#define PL080_CCTRL_DI 0x08000000
|
|
|
|
#define PL080_CCTRL_SI 0x04000000
|
|
|
|
#define PL080_CCTRL_D 0x02000000
|
|
|
|
#define PL080_CCTRL_S 0x01000000
|
|
|
|
|
2010-12-23 20:19:57 +03:00
|
|
|
static const VMStateDescription vmstate_pl080_channel = {
|
|
|
|
.name = "pl080_channel",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_UINT32(src, pl080_channel),
|
|
|
|
VMSTATE_UINT32(dest, pl080_channel),
|
|
|
|
VMSTATE_UINT32(lli, pl080_channel),
|
|
|
|
VMSTATE_UINT32(ctrl, pl080_channel),
|
|
|
|
VMSTATE_UINT32(conf, pl080_channel),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_pl080 = {
|
|
|
|
.name = "pl080",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
2013-07-26 14:37:06 +04:00
|
|
|
VMSTATE_UINT8(tc_int, PL080State),
|
|
|
|
VMSTATE_UINT8(tc_mask, PL080State),
|
|
|
|
VMSTATE_UINT8(err_int, PL080State),
|
|
|
|
VMSTATE_UINT8(err_mask, PL080State),
|
|
|
|
VMSTATE_UINT32(conf, PL080State),
|
|
|
|
VMSTATE_UINT32(sync, PL080State),
|
|
|
|
VMSTATE_UINT32(req_single, PL080State),
|
|
|
|
VMSTATE_UINT32(req_burst, PL080State),
|
|
|
|
VMSTATE_UINT8(tc_int, PL080State),
|
|
|
|
VMSTATE_UINT8(tc_int, PL080State),
|
|
|
|
VMSTATE_UINT8(tc_int, PL080State),
|
|
|
|
VMSTATE_STRUCT_ARRAY(chan, PL080State, PL080_MAX_CHANNELS,
|
2010-12-23 20:19:57 +03:00
|
|
|
1, vmstate_pl080_channel, pl080_channel),
|
2013-07-26 14:37:06 +04:00
|
|
|
VMSTATE_INT32(running, PL080State),
|
2010-12-23 20:19:57 +03:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-04-09 05:32:52 +04:00
|
|
|
static const unsigned char pl080_id[] =
|
|
|
|
{ 0x80, 0x10, 0x04, 0x0a, 0x0d, 0xf0, 0x05, 0xb1 };
|
|
|
|
|
2006-09-23 21:40:58 +04:00
|
|
|
static const unsigned char pl081_id[] =
|
|
|
|
{ 0x81, 0x10, 0x04, 0x0a, 0x0d, 0xf0, 0x05, 0xb1 };
|
|
|
|
|
2013-07-26 14:37:06 +04:00
|
|
|
static void pl080_update(PL080State *s)
|
2006-04-09 05:32:52 +04:00
|
|
|
{
|
2018-08-20 13:24:33 +03:00
|
|
|
bool tclevel = (s->tc_int & s->tc_mask);
|
|
|
|
bool errlevel = (s->err_int & s->err_mask);
|
|
|
|
|
|
|
|
qemu_set_irq(s->interr, errlevel);
|
|
|
|
qemu_set_irq(s->inttc, tclevel);
|
|
|
|
qemu_set_irq(s->irq, errlevel || tclevel);
|
2006-04-09 05:32:52 +04:00
|
|
|
}
|
|
|
|
|
2013-07-26 14:37:06 +04:00
|
|
|
static void pl080_run(PL080State *s)
|
2006-04-09 05:32:52 +04:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int flow;
|
|
|
|
pl080_channel *ch;
|
|
|
|
int swidth;
|
|
|
|
int dwidth;
|
|
|
|
int xsize;
|
|
|
|
int n;
|
|
|
|
int src_id;
|
|
|
|
int dest_id;
|
|
|
|
int size;
|
2008-09-20 12:07:15 +04:00
|
|
|
uint8_t buff[4];
|
2006-04-09 05:32:52 +04:00
|
|
|
uint32_t req;
|
|
|
|
|
|
|
|
s->tc_mask = 0;
|
2006-09-23 21:40:58 +04:00
|
|
|
for (c = 0; c < s->nchannels; c++) {
|
2006-04-09 05:32:52 +04:00
|
|
|
if (s->chan[c].conf & PL080_CCONF_ITC)
|
|
|
|
s->tc_mask |= 1 << c;
|
|
|
|
if (s->chan[c].conf & PL080_CCONF_IE)
|
|
|
|
s->err_mask |= 1 << c;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((s->conf & PL080_CONF_E) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If we are already in the middle of a DMA operation then indicate that
|
|
|
|
there may be new DMA requests and return immediately. */
|
|
|
|
if (s->running) {
|
|
|
|
s->running++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s->running = 1;
|
|
|
|
while (s->running) {
|
2006-09-23 21:40:58 +04:00
|
|
|
for (c = 0; c < s->nchannels; c++) {
|
2006-04-09 05:32:52 +04:00
|
|
|
ch = &s->chan[c];
|
|
|
|
again:
|
|
|
|
/* Test if thiws channel has any pending DMA requests. */
|
|
|
|
if ((ch->conf & (PL080_CCONF_H | PL080_CCONF_E))
|
|
|
|
!= PL080_CCONF_E)
|
|
|
|
continue;
|
|
|
|
flow = (ch->conf >> 11) & 7;
|
|
|
|
if (flow >= 4) {
|
2009-05-08 05:35:15 +04:00
|
|
|
hw_error(
|
2006-04-09 05:32:52 +04:00
|
|
|
"pl080_run: Peripheral flow control not implemented\n");
|
|
|
|
}
|
|
|
|
src_id = (ch->conf >> 1) & 0x1f;
|
|
|
|
dest_id = (ch->conf >> 6) & 0x1f;
|
|
|
|
size = ch->ctrl & 0xfff;
|
|
|
|
req = s->req_single | s->req_burst;
|
|
|
|
switch (flow) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if ((req & (1u << dest_id)) == 0)
|
|
|
|
size = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if ((req & (1u << src_id)) == 0)
|
|
|
|
size = 0;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if ((req & (1u << src_id)) == 0
|
|
|
|
|| (req & (1u << dest_id)) == 0)
|
|
|
|
size = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!size)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Transfer one element. */
|
|
|
|
/* ??? Should transfer multiple elements for a burst request. */
|
|
|
|
/* ??? Unclear what the proper behavior is when source and
|
|
|
|
destination widths are different. */
|
|
|
|
swidth = 1 << ((ch->ctrl >> 18) & 7);
|
|
|
|
dwidth = 1 << ((ch->ctrl >> 21) & 7);
|
|
|
|
for (n = 0; n < dwidth; n+= swidth) {
|
2018-08-20 13:24:33 +03:00
|
|
|
address_space_read(&s->downstream_as, ch->src,
|
|
|
|
MEMTXATTRS_UNSPECIFIED, buff + n, swidth);
|
2006-04-09 05:32:52 +04:00
|
|
|
if (ch->ctrl & PL080_CCTRL_SI)
|
|
|
|
ch->src += swidth;
|
|
|
|
}
|
|
|
|
xsize = (dwidth < swidth) ? swidth : dwidth;
|
|
|
|
/* ??? This may pad the value incorrectly for dwidth < 32. */
|
|
|
|
for (n = 0; n < xsize; n += dwidth) {
|
2018-08-20 13:24:33 +03:00
|
|
|
address_space_write(&s->downstream_as, ch->dest + n,
|
|
|
|
MEMTXATTRS_UNSPECIFIED, buff + n, dwidth);
|
2006-04-09 05:32:52 +04:00
|
|
|
if (ch->ctrl & PL080_CCTRL_DI)
|
|
|
|
ch->dest += swidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
size--;
|
|
|
|
ch->ctrl = (ch->ctrl & 0xfffff000) | size;
|
|
|
|
if (size == 0) {
|
|
|
|
/* Transfer complete. */
|
|
|
|
if (ch->lli) {
|
2018-08-20 13:24:33 +03:00
|
|
|
ch->src = address_space_ldl_le(&s->downstream_as,
|
Switch non-CPU callers from ld/st*_phys to address_space_ld/st*
Switch all the uses of ld/st*_phys to address_space_ld/st*,
except for those cases where the address space is the CPU's
(ie cs->as). This was done with the following script which
generates a Coccinelle patch.
A few over-80-columns lines in the result were rewrapped by
hand where Coccinelle failed to do the wrapping automatically,
as well as one location where it didn't put a line-continuation
'\' when wrapping lines on a change made to a match inside
a macro definition.
===begin===
#!/bin/sh -e
# Usage:
# ./ldst-phys.spatch.sh > ldst-phys.spatch
# spatch -sp_file ldst-phys.spatch -dir . | sed -e '/^+/s/\t/ /g' > out.patch
# patch -p1 < out.patch
for FN in ub uw_le uw_be l_le l_be q_le q_be uw l q; do
cat <<EOF
@ cpu_matches_ld_${FN} @
expression E1,E2;
identifier as;
@@
ld${FN}_phys(E1->as,E2)
@ other_matches_ld_${FN} depends on !cpu_matches_ld_${FN} @
expression E1,E2;
@@
-ld${FN}_phys(E1,E2)
+address_space_ld${FN}(E1,E2, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
for FN in b w_le w_be l_le l_be q_le q_be w l q; do
cat <<EOF
@ cpu_matches_st_${FN} @
expression E1,E2,E3;
identifier as;
@@
st${FN}_phys(E1->as,E2,E3)
@ other_matches_st_${FN} depends on !cpu_matches_st_${FN} @
expression E1,E2,E3;
@@
-st${FN}_phys(E1,E2,E3)
+address_space_st${FN}(E1,E2,E3, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
===endit===
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2015-04-26 18:49:24 +03:00
|
|
|
ch->lli,
|
|
|
|
MEMTXATTRS_UNSPECIFIED,
|
|
|
|
NULL);
|
2018-08-20 13:24:33 +03:00
|
|
|
ch->dest = address_space_ldl_le(&s->downstream_as,
|
Switch non-CPU callers from ld/st*_phys to address_space_ld/st*
Switch all the uses of ld/st*_phys to address_space_ld/st*,
except for those cases where the address space is the CPU's
(ie cs->as). This was done with the following script which
generates a Coccinelle patch.
A few over-80-columns lines in the result were rewrapped by
hand where Coccinelle failed to do the wrapping automatically,
as well as one location where it didn't put a line-continuation
'\' when wrapping lines on a change made to a match inside
a macro definition.
===begin===
#!/bin/sh -e
# Usage:
# ./ldst-phys.spatch.sh > ldst-phys.spatch
# spatch -sp_file ldst-phys.spatch -dir . | sed -e '/^+/s/\t/ /g' > out.patch
# patch -p1 < out.patch
for FN in ub uw_le uw_be l_le l_be q_le q_be uw l q; do
cat <<EOF
@ cpu_matches_ld_${FN} @
expression E1,E2;
identifier as;
@@
ld${FN}_phys(E1->as,E2)
@ other_matches_ld_${FN} depends on !cpu_matches_ld_${FN} @
expression E1,E2;
@@
-ld${FN}_phys(E1,E2)
+address_space_ld${FN}(E1,E2, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
for FN in b w_le w_be l_le l_be q_le q_be w l q; do
cat <<EOF
@ cpu_matches_st_${FN} @
expression E1,E2,E3;
identifier as;
@@
st${FN}_phys(E1->as,E2,E3)
@ other_matches_st_${FN} depends on !cpu_matches_st_${FN} @
expression E1,E2,E3;
@@
-st${FN}_phys(E1,E2,E3)
+address_space_st${FN}(E1,E2,E3, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
===endit===
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2015-04-26 18:49:24 +03:00
|
|
|
ch->lli + 4,
|
|
|
|
MEMTXATTRS_UNSPECIFIED,
|
|
|
|
NULL);
|
2018-08-20 13:24:33 +03:00
|
|
|
ch->ctrl = address_space_ldl_le(&s->downstream_as,
|
Switch non-CPU callers from ld/st*_phys to address_space_ld/st*
Switch all the uses of ld/st*_phys to address_space_ld/st*,
except for those cases where the address space is the CPU's
(ie cs->as). This was done with the following script which
generates a Coccinelle patch.
A few over-80-columns lines in the result were rewrapped by
hand where Coccinelle failed to do the wrapping automatically,
as well as one location where it didn't put a line-continuation
'\' when wrapping lines on a change made to a match inside
a macro definition.
===begin===
#!/bin/sh -e
# Usage:
# ./ldst-phys.spatch.sh > ldst-phys.spatch
# spatch -sp_file ldst-phys.spatch -dir . | sed -e '/^+/s/\t/ /g' > out.patch
# patch -p1 < out.patch
for FN in ub uw_le uw_be l_le l_be q_le q_be uw l q; do
cat <<EOF
@ cpu_matches_ld_${FN} @
expression E1,E2;
identifier as;
@@
ld${FN}_phys(E1->as,E2)
@ other_matches_ld_${FN} depends on !cpu_matches_ld_${FN} @
expression E1,E2;
@@
-ld${FN}_phys(E1,E2)
+address_space_ld${FN}(E1,E2, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
for FN in b w_le w_be l_le l_be q_le q_be w l q; do
cat <<EOF
@ cpu_matches_st_${FN} @
expression E1,E2,E3;
identifier as;
@@
st${FN}_phys(E1->as,E2,E3)
@ other_matches_st_${FN} depends on !cpu_matches_st_${FN} @
expression E1,E2,E3;
@@
-st${FN}_phys(E1,E2,E3)
+address_space_st${FN}(E1,E2,E3, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
===endit===
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2015-04-26 18:49:24 +03:00
|
|
|
ch->lli + 12,
|
|
|
|
MEMTXATTRS_UNSPECIFIED,
|
|
|
|
NULL);
|
2018-08-20 13:24:33 +03:00
|
|
|
ch->lli = address_space_ldl_le(&s->downstream_as,
|
Switch non-CPU callers from ld/st*_phys to address_space_ld/st*
Switch all the uses of ld/st*_phys to address_space_ld/st*,
except for those cases where the address space is the CPU's
(ie cs->as). This was done with the following script which
generates a Coccinelle patch.
A few over-80-columns lines in the result were rewrapped by
hand where Coccinelle failed to do the wrapping automatically,
as well as one location where it didn't put a line-continuation
'\' when wrapping lines on a change made to a match inside
a macro definition.
===begin===
#!/bin/sh -e
# Usage:
# ./ldst-phys.spatch.sh > ldst-phys.spatch
# spatch -sp_file ldst-phys.spatch -dir . | sed -e '/^+/s/\t/ /g' > out.patch
# patch -p1 < out.patch
for FN in ub uw_le uw_be l_le l_be q_le q_be uw l q; do
cat <<EOF
@ cpu_matches_ld_${FN} @
expression E1,E2;
identifier as;
@@
ld${FN}_phys(E1->as,E2)
@ other_matches_ld_${FN} depends on !cpu_matches_ld_${FN} @
expression E1,E2;
@@
-ld${FN}_phys(E1,E2)
+address_space_ld${FN}(E1,E2, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
for FN in b w_le w_be l_le l_be q_le q_be w l q; do
cat <<EOF
@ cpu_matches_st_${FN} @
expression E1,E2,E3;
identifier as;
@@
st${FN}_phys(E1->as,E2,E3)
@ other_matches_st_${FN} depends on !cpu_matches_st_${FN} @
expression E1,E2,E3;
@@
-st${FN}_phys(E1,E2,E3)
+address_space_st${FN}(E1,E2,E3, MEMTXATTRS_UNSPECIFIED, NULL)
EOF
done
===endit===
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2015-04-26 18:49:24 +03:00
|
|
|
ch->lli + 8,
|
|
|
|
MEMTXATTRS_UNSPECIFIED,
|
|
|
|
NULL);
|
2006-04-09 05:32:52 +04:00
|
|
|
} else {
|
|
|
|
ch->conf &= ~PL080_CCONF_E;
|
|
|
|
}
|
|
|
|
if (ch->ctrl & PL080_CCTRL_I) {
|
|
|
|
s->tc_int |= 1 << c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
if (--s->running)
|
|
|
|
s->running = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint64_t pl080_read(void *opaque, hwaddr offset,
|
2011-10-10 19:18:44 +04:00
|
|
|
unsigned size)
|
2006-04-09 05:32:52 +04:00
|
|
|
{
|
2013-07-26 14:37:06 +04:00
|
|
|
PL080State *s = (PL080State *)opaque;
|
2006-04-09 05:32:52 +04:00
|
|
|
uint32_t i;
|
|
|
|
uint32_t mask;
|
|
|
|
|
|
|
|
if (offset >= 0xfe0 && offset < 0x1000) {
|
2006-09-23 21:40:58 +04:00
|
|
|
if (s->nchannels == 8) {
|
|
|
|
return pl080_id[(offset - 0xfe0) >> 2];
|
|
|
|
} else {
|
|
|
|
return pl081_id[(offset - 0xfe0) >> 2];
|
|
|
|
}
|
2006-04-09 05:32:52 +04:00
|
|
|
}
|
|
|
|
if (offset >= 0x100 && offset < 0x200) {
|
|
|
|
i = (offset & 0xe0) >> 5;
|
2006-09-23 21:40:58 +04:00
|
|
|
if (i >= s->nchannels)
|
|
|
|
goto bad_offset;
|
2018-08-20 13:24:33 +03:00
|
|
|
switch ((offset >> 2) & 7) {
|
2006-04-09 05:32:52 +04:00
|
|
|
case 0: /* SrcAddr */
|
|
|
|
return s->chan[i].src;
|
|
|
|
case 1: /* DestAddr */
|
|
|
|
return s->chan[i].dest;
|
|
|
|
case 2: /* LLI */
|
|
|
|
return s->chan[i].lli;
|
|
|
|
case 3: /* Control */
|
|
|
|
return s->chan[i].ctrl;
|
|
|
|
case 4: /* Configuration */
|
|
|
|
return s->chan[i].conf;
|
|
|
|
default:
|
|
|
|
goto bad_offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (offset >> 2) {
|
|
|
|
case 0: /* IntStatus */
|
|
|
|
return (s->tc_int & s->tc_mask) | (s->err_int & s->err_mask);
|
|
|
|
case 1: /* IntTCStatus */
|
|
|
|
return (s->tc_int & s->tc_mask);
|
|
|
|
case 3: /* IntErrorStatus */
|
|
|
|
return (s->err_int & s->err_mask);
|
|
|
|
case 5: /* RawIntTCStatus */
|
|
|
|
return s->tc_int;
|
|
|
|
case 6: /* RawIntErrorStatus */
|
|
|
|
return s->err_int;
|
|
|
|
case 7: /* EnbldChns */
|
|
|
|
mask = 0;
|
2006-09-23 21:40:58 +04:00
|
|
|
for (i = 0; i < s->nchannels; i++) {
|
2006-04-09 05:32:52 +04:00
|
|
|
if (s->chan[i].conf & PL080_CCONF_E)
|
|
|
|
mask |= 1 << i;
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
case 8: /* SoftBReq */
|
|
|
|
case 9: /* SoftSReq */
|
|
|
|
case 10: /* SoftLBReq */
|
|
|
|
case 11: /* SoftLSReq */
|
|
|
|
/* ??? Implement these. */
|
|
|
|
return 0;
|
|
|
|
case 12: /* Configuration */
|
|
|
|
return s->conf;
|
|
|
|
case 13: /* Sync */
|
|
|
|
return s->sync;
|
|
|
|
default:
|
|
|
|
bad_offset:
|
2012-10-30 11:45:09 +04:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
|
|
"pl080_read: Bad offset %x\n", (int)offset);
|
2006-04-09 05:32:52 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void pl080_write(void *opaque, hwaddr offset,
|
2011-10-10 19:18:44 +04:00
|
|
|
uint64_t value, unsigned size)
|
2006-04-09 05:32:52 +04:00
|
|
|
{
|
2013-07-26 14:37:06 +04:00
|
|
|
PL080State *s = (PL080State *)opaque;
|
2006-04-09 05:32:52 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (offset >= 0x100 && offset < 0x200) {
|
|
|
|
i = (offset & 0xe0) >> 5;
|
2006-09-23 21:40:58 +04:00
|
|
|
if (i >= s->nchannels)
|
|
|
|
goto bad_offset;
|
2018-08-20 13:24:33 +03:00
|
|
|
switch ((offset >> 2) & 7) {
|
2006-04-09 05:32:52 +04:00
|
|
|
case 0: /* SrcAddr */
|
|
|
|
s->chan[i].src = value;
|
|
|
|
break;
|
|
|
|
case 1: /* DestAddr */
|
|
|
|
s->chan[i].dest = value;
|
|
|
|
break;
|
|
|
|
case 2: /* LLI */
|
|
|
|
s->chan[i].lli = value;
|
|
|
|
break;
|
|
|
|
case 3: /* Control */
|
|
|
|
s->chan[i].ctrl = value;
|
|
|
|
break;
|
|
|
|
case 4: /* Configuration */
|
|
|
|
s->chan[i].conf = value;
|
|
|
|
pl080_run(s);
|
|
|
|
break;
|
|
|
|
}
|
2018-08-20 13:24:33 +03:00
|
|
|
return;
|
2006-04-09 05:32:52 +04:00
|
|
|
}
|
|
|
|
switch (offset >> 2) {
|
|
|
|
case 2: /* IntTCClear */
|
|
|
|
s->tc_int &= ~value;
|
|
|
|
break;
|
|
|
|
case 4: /* IntErrorClear */
|
|
|
|
s->err_int &= ~value;
|
|
|
|
break;
|
|
|
|
case 8: /* SoftBReq */
|
|
|
|
case 9: /* SoftSReq */
|
|
|
|
case 10: /* SoftLBReq */
|
|
|
|
case 11: /* SoftLSReq */
|
|
|
|
/* ??? Implement these. */
|
2012-10-30 11:45:09 +04:00
|
|
|
qemu_log_mask(LOG_UNIMP, "pl080_write: Soft DMA not implemented\n");
|
2006-04-09 05:32:52 +04:00
|
|
|
break;
|
|
|
|
case 12: /* Configuration */
|
|
|
|
s->conf = value;
|
2016-10-17 21:22:17 +03:00
|
|
|
if (s->conf & (PL080_CONF_M1 | PL080_CONF_M2)) {
|
2012-10-30 11:45:09 +04:00
|
|
|
qemu_log_mask(LOG_UNIMP,
|
|
|
|
"pl080_write: Big-endian DMA not implemented\n");
|
2006-04-09 05:32:52 +04:00
|
|
|
}
|
|
|
|
pl080_run(s);
|
|
|
|
break;
|
|
|
|
case 13: /* Sync */
|
|
|
|
s->sync = value;
|
|
|
|
break;
|
|
|
|
default:
|
2006-09-23 21:40:58 +04:00
|
|
|
bad_offset:
|
2012-10-30 11:45:09 +04:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
|
|
"pl080_write: Bad offset %x\n", (int)offset);
|
2006-04-09 05:32:52 +04:00
|
|
|
}
|
|
|
|
pl080_update(s);
|
|
|
|
}
|
|
|
|
|
2011-10-10 19:18:44 +04:00
|
|
|
static const MemoryRegionOps pl080_ops = {
|
|
|
|
.read = pl080_read,
|
|
|
|
.write = pl080_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2006-04-09 05:32:52 +04:00
|
|
|
};
|
|
|
|
|
2018-08-20 13:24:33 +03:00
|
|
|
static void pl080_reset(DeviceState *dev)
|
|
|
|
{
|
|
|
|
PL080State *s = PL080(dev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
s->tc_int = 0;
|
|
|
|
s->tc_mask = 0;
|
|
|
|
s->err_int = 0;
|
|
|
|
s->err_mask = 0;
|
|
|
|
s->conf = 0;
|
|
|
|
s->sync = 0;
|
|
|
|
s->req_single = 0;
|
|
|
|
s->req_burst = 0;
|
|
|
|
s->running = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < s->nchannels; i++) {
|
|
|
|
s->chan[i].src = 0;
|
|
|
|
s->chan[i].dest = 0;
|
|
|
|
s->chan[i].lli = 0;
|
|
|
|
s->chan[i].ctrl = 0;
|
|
|
|
s->chan[i].conf = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-26 14:47:17 +04:00
|
|
|
static void pl080_init(Object *obj)
|
2006-04-09 05:32:52 +04:00
|
|
|
{
|
2013-07-26 14:47:17 +04:00
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
PL080State *s = PL080(obj);
|
2006-04-09 05:32:52 +04:00
|
|
|
|
2013-06-07 05:25:08 +04:00
|
|
|
memory_region_init_io(&s->iomem, OBJECT(s), &pl080_ops, s, "pl080", 0x1000);
|
2013-07-26 14:47:17 +04:00
|
|
|
sysbus_init_mmio(sbd, &s->iomem);
|
|
|
|
sysbus_init_irq(sbd, &s->irq);
|
2018-08-20 13:24:33 +03:00
|
|
|
sysbus_init_irq(sbd, &s->interr);
|
|
|
|
sysbus_init_irq(sbd, &s->inttc);
|
2013-07-26 14:47:17 +04:00
|
|
|
s->nchannels = 8;
|
2006-04-09 05:32:52 +04:00
|
|
|
}
|
2009-05-15 01:35:08 +04:00
|
|
|
|
2018-08-20 13:24:33 +03:00
|
|
|
static void pl080_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
PL080State *s = PL080(dev);
|
|
|
|
|
|
|
|
if (!s->downstream) {
|
|
|
|
error_setg(errp, "PL080 'downstream' link not set");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
address_space_init(&s->downstream_as, s->downstream, "pl080-downstream");
|
|
|
|
}
|
|
|
|
|
2013-07-26 14:47:17 +04:00
|
|
|
static void pl081_init(Object *obj)
|
2009-05-15 01:35:08 +04:00
|
|
|
{
|
2013-07-26 14:47:17 +04:00
|
|
|
PL080State *s = PL080(obj);
|
2009-05-15 01:35:08 +04:00
|
|
|
|
2013-07-26 14:47:17 +04:00
|
|
|
s->nchannels = 2;
|
2009-05-15 01:35:08 +04:00
|
|
|
}
|
|
|
|
|
2018-08-20 13:24:33 +03:00
|
|
|
static Property pl080_properties[] = {
|
|
|
|
DEFINE_PROP_LINK("downstream", PL080State, downstream,
|
|
|
|
TYPE_MEMORY_REGION, MemoryRegion *),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
2013-07-26 14:47:17 +04:00
|
|
|
static void pl080_class_init(ObjectClass *oc, void *data)
|
2012-01-24 23:12:29 +04:00
|
|
|
{
|
2013-07-26 14:47:17 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2011-12-08 07:34:16 +04:00
|
|
|
dc->vmsd = &vmstate_pl080;
|
2018-08-20 13:24:33 +03:00
|
|
|
dc->realize = pl080_realize;
|
|
|
|
dc->props = pl080_properties;
|
2018-08-20 13:24:33 +03:00
|
|
|
dc->reset = pl080_reset;
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo pl080_info = {
|
2013-07-26 14:47:17 +04:00
|
|
|
.name = TYPE_PL080,
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
2013-07-26 14:37:06 +04:00
|
|
|
.instance_size = sizeof(PL080State),
|
2013-07-26 14:47:17 +04:00
|
|
|
.instance_init = pl080_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = pl080_class_init,
|
2010-12-23 20:19:57 +03:00
|
|
|
};
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo pl081_info = {
|
2018-08-20 13:24:33 +03:00
|
|
|
.name = TYPE_PL081,
|
2013-07-26 14:47:17 +04:00
|
|
|
.parent = TYPE_PL080,
|
|
|
|
.instance_init = pl081_init,
|
2010-12-23 20:19:57 +03:00
|
|
|
};
|
|
|
|
|
2009-05-15 01:35:08 +04:00
|
|
|
/* The PL080 and PL081 are the same except for the number of channels
|
|
|
|
they implement (8 and 2 respectively). */
|
2012-02-09 18:20:55 +04:00
|
|
|
static void pl080_register_types(void)
|
2009-05-15 01:35:08 +04:00
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
type_register_static(&pl080_info);
|
|
|
|
type_register_static(&pl081_info);
|
2009-05-15 01:35:08 +04:00
|
|
|
}
|
|
|
|
|
2012-02-09 18:20:55 +04:00
|
|
|
type_init(pl080_register_types)
|