2016-01-29 23:50:38 +01:00
|
|
|
/*
|
|
|
|
* Raspberry Pi emulation (c) 2012 Gregory Estrade
|
2020-03-23 18:22:30 +01:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
2016-01-29 23:50:38 +01:00
|
|
|
*/
|
|
|
|
|
2016-02-08 20:01:23 +01:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2016-01-29 23:50:38 +01:00
|
|
|
#include "hw/misc/bcm2835_property.h"
|
2019-08-12 07:23:51 +02:00
|
|
|
#include "hw/qdev-properties.h"
|
2019-08-12 07:23:45 +02:00
|
|
|
#include "migration/vmstate.h"
|
2019-08-12 07:23:42 +02:00
|
|
|
#include "hw/irq.h"
|
2016-01-29 23:50:38 +01:00
|
|
|
#include "hw/misc/bcm2835_mbox_defs.h"
|
|
|
|
#include "sysemu/dma.h"
|
2015-12-15 13:16:16 +01:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2019-09-26 19:34:15 +02:00
|
|
|
#include "trace.h"
|
2016-01-29 23:50:38 +01:00
|
|
|
|
|
|
|
/* https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface */
|
|
|
|
|
|
|
|
static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
|
|
|
|
{
|
|
|
|
uint32_t tag;
|
|
|
|
uint32_t bufsize;
|
|
|
|
uint32_t tot_len;
|
|
|
|
size_t resplen;
|
|
|
|
uint32_t tmp;
|
2016-03-16 18:06:01 +01:00
|
|
|
int n;
|
|
|
|
uint32_t offset, length, color;
|
2018-08-24 14:17:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the current state of the framebuffer config; we will update
|
|
|
|
* this copy as we process tags and then ask the framebuffer to use
|
|
|
|
* it at the end.
|
|
|
|
*/
|
|
|
|
BCM2835FBConfig fbconfig = s->fbdev->config;
|
|
|
|
bool fbconfig_updated = false;
|
2016-01-29 23:50:38 +01:00
|
|
|
|
|
|
|
value &= ~0xf;
|
|
|
|
|
|
|
|
s->addr = value;
|
|
|
|
|
2016-03-04 12:30:18 +01:00
|
|
|
tot_len = ldl_le_phys(&s->dma_as, value);
|
2016-01-29 23:50:38 +01:00
|
|
|
|
|
|
|
/* @(addr + 4) : Buffer response code */
|
|
|
|
value = s->addr + 8;
|
|
|
|
while (value + 8 <= s->addr + tot_len) {
|
2016-03-04 12:30:18 +01:00
|
|
|
tag = ldl_le_phys(&s->dma_as, value);
|
|
|
|
bufsize = ldl_le_phys(&s->dma_as, value + 4);
|
2016-01-29 23:50:38 +01:00
|
|
|
/* @(value + 8) : Request/response indicator */
|
|
|
|
resplen = 0;
|
|
|
|
switch (tag) {
|
|
|
|
case 0x00000000: /* End tag */
|
|
|
|
break;
|
|
|
|
case 0x00000001: /* Get firmware revision */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 12, 346337);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00010001: /* Get board model */
|
|
|
|
qemu_log_mask(LOG_UNIMP,
|
2019-09-26 19:34:10 +02:00
|
|
|
"bcm2835_property: 0x%08x get board model NYI\n",
|
|
|
|
tag);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00010002: /* Get board revision */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 12, s->board_rev);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00010003: /* Get board MAC address */
|
|
|
|
resplen = sizeof(s->macaddr.a);
|
dma: Let dma_memory_read/write() take MemTxAttrs argument
Let devices specify transaction attributes when calling
dma_memory_read() or dma_memory_write().
Patch created mechanically using spatch with this script:
@@
expression E1, E2, E3, E4;
@@
(
- dma_memory_read(E1, E2, E3, E4)
+ dma_memory_read(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED)
|
- dma_memory_write(E1, E2, E3, E4)
+ dma_memory_write(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED)
)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20211223115554.3155328-6-philmd@redhat.com>
2020-09-03 10:08:29 +02:00
|
|
|
dma_memory_write(&s->dma_as, value + 12, s->macaddr.a, resplen,
|
|
|
|
MEMTXATTRS_UNSPECIFIED);
|
2016-01-29 23:50:38 +01:00
|
|
|
break;
|
|
|
|
case 0x00010004: /* Get board serial */
|
|
|
|
qemu_log_mask(LOG_UNIMP,
|
2019-09-26 19:34:10 +02:00
|
|
|
"bcm2835_property: 0x%08x get board serial NYI\n",
|
|
|
|
tag);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x00010005: /* Get ARM memory */
|
|
|
|
/* base */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 12, 0);
|
2016-01-29 23:50:38 +01:00
|
|
|
/* size */
|
2016-03-16 18:06:01 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, s->fbdev->vcram_base);
|
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x00010006: /* Get VC memory */
|
|
|
|
/* base */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, s->fbdev->vcram_base);
|
|
|
|
/* size */
|
|
|
|
stl_le_phys(&s->dma_as, value + 16, s->fbdev->vcram_size);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x00028001: /* Set power state */
|
|
|
|
/* Assume that whatever device they asked for exists,
|
|
|
|
* and we'll just claim we set it to the desired state
|
|
|
|
*/
|
2016-03-04 12:30:18 +01:00
|
|
|
tmp = ldl_le_phys(&s->dma_as, value + 16);
|
|
|
|
stl_le_phys(&s->dma_as, value + 16, (tmp & 1));
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Clocks */
|
|
|
|
|
|
|
|
case 0x00030001: /* Get clock state */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, 0x1);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x00038001: /* Set clock state */
|
|
|
|
qemu_log_mask(LOG_UNIMP,
|
2019-09-26 19:34:10 +02:00
|
|
|
"bcm2835_property: 0x%08x set clock state NYI\n",
|
|
|
|
tag);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x00030002: /* Get clock rate */
|
|
|
|
case 0x00030004: /* Get max clock rate */
|
|
|
|
case 0x00030007: /* Get min clock rate */
|
2016-03-04 12:30:18 +01:00
|
|
|
switch (ldl_le_phys(&s->dma_as, value + 12)) {
|
2016-01-29 23:50:38 +01:00
|
|
|
case 1: /* EMMC */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, 50000000);
|
2016-01-29 23:50:38 +01:00
|
|
|
break;
|
|
|
|
case 2: /* UART */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, 3000000);
|
2016-01-29 23:50:38 +01:00
|
|
|
break;
|
|
|
|
default:
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, 700000000);
|
2016-01-29 23:50:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x00038002: /* Set clock rate */
|
|
|
|
case 0x00038004: /* Set max clock rate */
|
|
|
|
case 0x00038007: /* Set min clock rate */
|
|
|
|
qemu_log_mask(LOG_UNIMP,
|
2019-09-26 19:34:10 +02:00
|
|
|
"bcm2835_property: 0x%08x set clock rate NYI\n",
|
|
|
|
tag);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Temperature */
|
|
|
|
|
|
|
|
case 0x00030006: /* Get temperature */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, 25000);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0003000A: /* Get max temperature */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 16, 99000);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
|
2016-03-16 18:06:01 +01:00
|
|
|
/* Frame buffer */
|
|
|
|
|
|
|
|
case 0x00040001: /* Allocate buffer */
|
2018-08-24 14:17:48 +02:00
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.base);
|
2016-05-12 14:22:25 +02:00
|
|
|
stl_le_phys(&s->dma_as, value + 16,
|
2018-08-24 14:17:49 +02:00
|
|
|
bcm2835_fb_get_size(&fbconfig));
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x00048001: /* Release buffer */
|
|
|
|
resplen = 0;
|
|
|
|
break;
|
|
|
|
case 0x00040002: /* Blank screen */
|
|
|
|
resplen = 4;
|
|
|
|
break;
|
2018-08-24 14:17:49 +02:00
|
|
|
case 0x00044003: /* Test physical display width/height */
|
|
|
|
case 0x00044004: /* Test virtual display width/height */
|
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x00048003: /* Set physical display width/height */
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig.xres = ldl_le_phys(&s->dma_as, value + 12);
|
|
|
|
fbconfig.yres = ldl_le_phys(&s->dma_as, value + 16);
|
2018-08-24 14:17:50 +02:00
|
|
|
bcm2835_fb_validate_config(&fbconfig);
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig_updated = true;
|
2018-08-24 14:17:50 +02:00
|
|
|
/* fall through */
|
|
|
|
case 0x00040003: /* Get physical display width/height */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.xres);
|
|
|
|
stl_le_phys(&s->dma_as, value + 16, fbconfig.yres);
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
2018-08-24 14:17:49 +02:00
|
|
|
case 0x00048004: /* Set virtual display width/height */
|
|
|
|
fbconfig.xres_virtual = ldl_le_phys(&s->dma_as, value + 12);
|
|
|
|
fbconfig.yres_virtual = ldl_le_phys(&s->dma_as, value + 16);
|
2018-08-24 14:17:50 +02:00
|
|
|
bcm2835_fb_validate_config(&fbconfig);
|
2018-08-24 14:17:49 +02:00
|
|
|
fbconfig_updated = true;
|
2018-08-24 14:17:50 +02:00
|
|
|
/* fall through */
|
|
|
|
case 0x00040004: /* Get virtual display width/height */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.xres_virtual);
|
|
|
|
stl_le_phys(&s->dma_as, value + 16, fbconfig.yres_virtual);
|
2018-08-24 14:17:49 +02:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
2016-03-16 18:06:01 +01:00
|
|
|
case 0x00044005: /* Test depth */
|
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00048005: /* Set depth */
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig.bpp = ldl_le_phys(&s->dma_as, value + 12);
|
2018-08-24 14:17:50 +02:00
|
|
|
bcm2835_fb_validate_config(&fbconfig);
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig_updated = true;
|
2018-08-24 14:17:50 +02:00
|
|
|
/* fall through */
|
|
|
|
case 0x00040005: /* Get depth */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.bpp);
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00044006: /* Test pixel order */
|
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00048006: /* Set pixel order */
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig.pixo = ldl_le_phys(&s->dma_as, value + 12);
|
2018-08-24 14:17:50 +02:00
|
|
|
bcm2835_fb_validate_config(&fbconfig);
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig_updated = true;
|
2018-08-24 14:17:50 +02:00
|
|
|
/* fall through */
|
|
|
|
case 0x00040006: /* Get pixel order */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.pixo);
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00044007: /* Test pixel alpha */
|
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00048007: /* Set alpha */
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig.alpha = ldl_le_phys(&s->dma_as, value + 12);
|
2018-08-24 14:17:50 +02:00
|
|
|
bcm2835_fb_validate_config(&fbconfig);
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig_updated = true;
|
2018-08-24 14:17:50 +02:00
|
|
|
/* fall through */
|
|
|
|
case 0x00040007: /* Get alpha */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.alpha);
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00040008: /* Get pitch */
|
2018-08-24 14:17:48 +02:00
|
|
|
stl_le_phys(&s->dma_as, value + 12,
|
2018-08-24 14:17:49 +02:00
|
|
|
bcm2835_fb_get_pitch(&fbconfig));
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
case 0x00044009: /* Test virtual offset */
|
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x00048009: /* Set virtual offset */
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig.xoffset = ldl_le_phys(&s->dma_as, value + 12);
|
|
|
|
fbconfig.yoffset = ldl_le_phys(&s->dma_as, value + 16);
|
2018-08-24 14:17:50 +02:00
|
|
|
bcm2835_fb_validate_config(&fbconfig);
|
2018-08-24 14:17:48 +02:00
|
|
|
fbconfig_updated = true;
|
2018-08-24 14:17:50 +02:00
|
|
|
/* fall through */
|
|
|
|
case 0x00040009: /* Get virtual offset */
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, fbconfig.xoffset);
|
|
|
|
stl_le_phys(&s->dma_as, value + 16, fbconfig.yoffset);
|
2016-03-16 18:06:01 +01:00
|
|
|
resplen = 8;
|
|
|
|
break;
|
|
|
|
case 0x0004000a: /* Get/Test/Set overscan */
|
|
|
|
case 0x0004400a:
|
|
|
|
case 0x0004800a:
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, 0);
|
|
|
|
stl_le_phys(&s->dma_as, value + 16, 0);
|
|
|
|
stl_le_phys(&s->dma_as, value + 20, 0);
|
|
|
|
stl_le_phys(&s->dma_as, value + 24, 0);
|
|
|
|
resplen = 16;
|
|
|
|
break;
|
|
|
|
case 0x0004800b: /* Set palette */
|
|
|
|
offset = ldl_le_phys(&s->dma_as, value + 12);
|
|
|
|
length = ldl_le_phys(&s->dma_as, value + 16);
|
|
|
|
n = 0;
|
|
|
|
while (n < length - offset) {
|
|
|
|
color = ldl_le_phys(&s->dma_as, value + 20 + (n << 2));
|
|
|
|
stl_le_phys(&s->dma_as,
|
|
|
|
s->fbdev->vcram_base + ((offset + n) << 2), color);
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
stl_le_phys(&s->dma_as, value + 12, 0);
|
|
|
|
resplen = 4;
|
|
|
|
break;
|
2016-01-29 23:50:38 +01:00
|
|
|
|
|
|
|
case 0x00060001: /* Get DMA channels */
|
|
|
|
/* channels 2-5 */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 12, 0x003C);
|
2016-01-29 23:50:38 +01:00
|
|
|
resplen = 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x00050001: /* Get command line */
|
|
|
|
resplen = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-09-26 19:34:10 +02:00
|
|
|
qemu_log_mask(LOG_UNIMP,
|
|
|
|
"bcm2835_property: unhandled tag 0x%08x\n", tag);
|
2016-01-29 23:50:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-09-26 19:34:15 +02:00
|
|
|
trace_bcm2835_mbox_property(tag, bufsize, resplen);
|
2016-01-29 23:50:38 +01:00
|
|
|
if (tag == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, value + 8, (1 << 31) | resplen);
|
2016-01-29 23:50:38 +01:00
|
|
|
value += bufsize + 12;
|
|
|
|
}
|
|
|
|
|
2016-03-16 18:06:01 +01:00
|
|
|
/* Reconfigure framebuffer if required */
|
2018-08-24 14:17:48 +02:00
|
|
|
if (fbconfig_updated) {
|
|
|
|
bcm2835_fb_reconfigure(s->fbdev, &fbconfig);
|
2016-03-16 18:06:01 +01:00
|
|
|
}
|
|
|
|
|
2016-01-29 23:50:38 +01:00
|
|
|
/* Buffer response code */
|
2016-03-04 12:30:18 +01:00
|
|
|
stl_le_phys(&s->dma_as, s->addr + 4, (1 << 31));
|
2016-01-29 23:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t bcm2835_property_read(void *opaque, hwaddr offset,
|
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
BCM2835PropertyState *s = opaque;
|
|
|
|
uint32_t res = 0;
|
|
|
|
|
|
|
|
switch (offset) {
|
|
|
|
case MBOX_AS_DATA:
|
|
|
|
res = MBOX_CHAN_PROPERTY | s->addr;
|
|
|
|
s->pending = false;
|
|
|
|
qemu_set_irq(s->mbox_irq, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MBOX_AS_PENDING:
|
|
|
|
res = s->pending;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
|
|
|
|
__func__, offset);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_property_write(void *opaque, hwaddr offset,
|
|
|
|
uint64_t value, unsigned size)
|
|
|
|
{
|
|
|
|
BCM2835PropertyState *s = opaque;
|
|
|
|
|
|
|
|
switch (offset) {
|
|
|
|
case MBOX_AS_DATA:
|
|
|
|
/* bcm2835_mbox should check our pending status before pushing */
|
|
|
|
assert(!s->pending);
|
|
|
|
s->pending = true;
|
|
|
|
bcm2835_property_mbox_push(s, value);
|
|
|
|
qemu_set_irq(s->mbox_irq, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset %"HWADDR_PRIx"\n",
|
|
|
|
__func__, offset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps bcm2835_property_ops = {
|
|
|
|
.read = bcm2835_property_read,
|
|
|
|
.write = bcm2835_property_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid.min_access_size = 4,
|
|
|
|
.valid.max_access_size = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_bcm2835_property = {
|
|
|
|
.name = TYPE_BCM2835_PROPERTY,
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.fields = (VMStateField[]) {
|
|
|
|
VMSTATE_MACADDR(macaddr, BCM2835PropertyState),
|
|
|
|
VMSTATE_UINT32(addr, BCM2835PropertyState),
|
|
|
|
VMSTATE_BOOL(pending, BCM2835PropertyState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_property_init(Object *obj)
|
|
|
|
{
|
|
|
|
BCM2835PropertyState *s = BCM2835_PROPERTY(obj);
|
|
|
|
|
|
|
|
memory_region_init_io(&s->iomem, OBJECT(s), &bcm2835_property_ops, s,
|
|
|
|
TYPE_BCM2835_PROPERTY, 0x10);
|
|
|
|
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
|
|
|
|
sysbus_init_irq(SYS_BUS_DEVICE(s), &s->mbox_irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_property_reset(DeviceState *dev)
|
|
|
|
{
|
|
|
|
BCM2835PropertyState *s = BCM2835_PROPERTY(dev);
|
|
|
|
|
|
|
|
s->pending = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcm2835_property_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
BCM2835PropertyState *s = BCM2835_PROPERTY(dev);
|
|
|
|
Object *obj;
|
2016-03-16 18:06:01 +01:00
|
|
|
|
2020-07-07 18:05:52 +02:00
|
|
|
obj = object_property_get_link(OBJECT(dev), "fb", &error_abort);
|
2016-03-16 18:06:01 +01:00
|
|
|
s->fbdev = BCM2835_FB(obj);
|
|
|
|
|
2020-07-07 18:05:52 +02:00
|
|
|
obj = object_property_get_link(OBJECT(dev), "dma-mr", &error_abort);
|
2016-01-29 23:50:38 +01:00
|
|
|
s->dma_mr = MEMORY_REGION(obj);
|
hw/arm/bcm2835_peripherals: Name various address spaces
Various address spaces from the BCM2835 are reported as
'anonymous' in memory tree:
(qemu) info mtree
address-space: anonymous
0000000000000000-000000000000008f (prio 0, i/o): bcm2835-mbox
0000000000000010-000000000000001f (prio 0, i/o): bcm2835-fb
0000000000000080-000000000000008f (prio 0, i/o): bcm2835-property
address-space: anonymous
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
[...]
Since the address_space_init() function takes a 'name' argument,
set it to correctly describe each address space:
(qemu) info mtree
address-space: bcm2835-mbox-memory
0000000000000000-000000000000008f (prio 0, i/o): bcm2835-mbox
0000000000000010-000000000000001f (prio 0, i/o): bcm2835-fb
0000000000000080-000000000000008f (prio 0, i/o): bcm2835-property
address-space: bcm2835-fb-memory
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
address-space: bcm2835-property-memory
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
address-space: bcm2835-dma-memory
0000000000000000-00000000ffffffff (prio 0, i/o): bcm2835-gpu
0000000000000000-000000003fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
0000000040000000-000000007fffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
000000007e000000-000000007effffff (prio 1, i/o): alias bcm2835-peripherals @bcm2835-peripherals 0000000000000000-0000000000ffffff
0000000080000000-00000000bfffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
00000000c0000000-00000000ffffffff (prio 0, i/o): alias bcm2835-gpu-ram-alias[*] @ram 0000000000000000-000000003fffffff
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Message-id: 20190926173428.10713-4-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-09-26 19:34:11 +02:00
|
|
|
address_space_init(&s->dma_as, s->dma_mr, TYPE_BCM2835_PROPERTY "-memory");
|
2016-01-29 23:50:38 +01:00
|
|
|
|
|
|
|
/* TODO: connect to MAC address of USB NIC device, once we emulate it */
|
|
|
|
qemu_macaddr_default_if_unset(&s->macaddr);
|
|
|
|
|
|
|
|
bcm2835_property_reset(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Property bcm2835_property_props[] = {
|
2016-02-11 12:17:32 +01:00
|
|
|
DEFINE_PROP_UINT32("board-rev", BCM2835PropertyState, board_rev, 0),
|
2016-01-29 23:50:38 +01:00
|
|
|
DEFINE_PROP_END_OF_LIST()
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_property_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
2020-01-10 16:30:32 +01:00
|
|
|
device_class_set_props(dc, bcm2835_property_props);
|
2016-01-29 23:50:38 +01:00
|
|
|
dc->realize = bcm2835_property_realize;
|
|
|
|
dc->vmsd = &vmstate_bcm2835_property;
|
|
|
|
}
|
|
|
|
|
2022-01-17 15:58:04 +01:00
|
|
|
static const TypeInfo bcm2835_property_info = {
|
2016-01-29 23:50:38 +01:00
|
|
|
.name = TYPE_BCM2835_PROPERTY,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(BCM2835PropertyState),
|
|
|
|
.class_init = bcm2835_property_class_init,
|
|
|
|
.instance_init = bcm2835_property_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bcm2835_property_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&bcm2835_property_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(bcm2835_property_register_types)
|