aboutsummaryrefslogtreecommitdiff
path: root/hw/display/bcm2835_fb.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-08-24 13:17:50 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-08-24 13:17:50 +0100
commitcfb7ba983857e40e88bd3219aaab908862581ac0 (patch)
treefc3ec94b9c2d3deedd701319379269fa5d846a30 /hw/display/bcm2835_fb.c
parentf8add62c0c8826ca0fa90e6e3a80b810f63fe1dd (diff)
downloadqemu-cfb7ba983857e40e88bd3219aaab908862581ac0.zip
qemu-cfb7ba983857e40e88bd3219aaab908862581ac0.tar.gz
qemu-cfb7ba983857e40e88bd3219aaab908862581ac0.tar.bz2
hw/display/bcm2835_fb: Validate bcm2835_fb_mbox_push() config
Refactor bcm2835_fb_mbox_push() to work by calling bcm2835_fb_validate_config() and bcm2835_fb_reconfigure(), so that config set this way is also validated. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20180814144436.679-9-peter.maydell@linaro.org
Diffstat (limited to 'hw/display/bcm2835_fb.c')
-rw-r--r--hw/display/bcm2835_fb.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
index 3edb8b5..d534d00 100644
--- a/hw/display/bcm2835_fb.c
+++ b/hw/display/bcm2835_fb.c
@@ -248,47 +248,46 @@ void bcm2835_fb_validate_config(BCM2835FBConfig *config)
}
}
+void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
+{
+ s->lock = true;
+
+ s->config = *newconfig;
+
+ s->invalidate = true;
+ qemu_console_resize(s->con, s->config.xres, s->config.yres);
+ s->lock = false;
+}
+
static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
{
uint32_t pitch;
uint32_t size;
+ BCM2835FBConfig newconf;
value &= ~0xf;
- s->lock = true;
+ newconf.xres = ldl_le_phys(&s->dma_as, value);
+ newconf.yres = ldl_le_phys(&s->dma_as, value + 4);
+ newconf.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
+ newconf.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
+ newconf.bpp = ldl_le_phys(&s->dma_as, value + 20);
+ newconf.xoffset = ldl_le_phys(&s->dma_as, value + 24);
+ newconf.yoffset = ldl_le_phys(&s->dma_as, value + 28);
- s->config.xres = ldl_le_phys(&s->dma_as, value);
- s->config.yres = ldl_le_phys(&s->dma_as, value + 4);
- s->config.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
- s->config.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
- s->config.bpp = ldl_le_phys(&s->dma_as, value + 20);
- s->config.xoffset = ldl_le_phys(&s->dma_as, value + 24);
- s->config.yoffset = ldl_le_phys(&s->dma_as, value + 28);
+ newconf.base = s->vcram_base | (value & 0xc0000000);
+ newconf.base += BCM2835_FB_OFFSET;
- s->config.base = s->vcram_base | (value & 0xc0000000);
- s->config.base += BCM2835_FB_OFFSET;
+ bcm2835_fb_validate_config(&newconf);
- pitch = bcm2835_fb_get_pitch(&s->config);
- size = bcm2835_fb_get_size(&s->config);
+ pitch = bcm2835_fb_get_pitch(&newconf);
+ size = bcm2835_fb_get_size(&newconf);
stl_le_phys(&s->dma_as, value + 16, pitch);
- stl_le_phys(&s->dma_as, value + 32, s->config.base);
+ stl_le_phys(&s->dma_as, value + 32, newconf.base);
stl_le_phys(&s->dma_as, value + 36, size);
- s->invalidate = true;
- qemu_console_resize(s->con, s->config.xres, s->config.yres);
- s->lock = false;
-}
-
-void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
-{
- s->lock = true;
-
- s->config = *newconfig;
-
- s->invalidate = true;
- qemu_console_resize(s->con, s->config.xres, s->config.yres);
- s->lock = false;
+ bcm2835_fb_reconfigure(s, &newconf);
}
static uint64_t bcm2835_fb_read(void *opaque, hwaddr offset, unsigned size)