|
|
391fb8 |
From 870ed93bb6c35e821031bbc3a3a297d0e60c67ab Mon Sep 17 00:00:00 2001
|
|
|
391fb8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
391fb8 |
Date: Mon, 22 Dec 2014 13:11:41 +0100
|
|
|
391fb8 |
Subject: [PATCH 10/15] fw_cfg_mem: expose the "data_width" property with
|
|
|
391fb8 |
fw_cfg_init_mem_wide()
|
|
|
391fb8 |
|
|
|
391fb8 |
We rebase fw_cfg_init_mem() to the new function for compatibility with
|
|
|
391fb8 |
current callers.
|
|
|
391fb8 |
|
|
|
391fb8 |
The behavior of the (big endian) multi-byte data reads is best shown
|
|
|
391fb8 |
with a qtest session. Here, we are reading the first six bytes of
|
|
|
391fb8 |
the UUID
|
|
|
391fb8 |
|
|
|
391fb8 |
$ arm-softmmu/qemu-system-arm -M virt -machine accel=qtest \
|
|
|
391fb8 |
-qtest stdio -uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8
|
|
|
391fb8 |
>>> writew 0x9020008 0x0200
|
|
|
391fb8 |
<<< OK
|
|
|
391fb8 |
>>> readl 0x9020000
|
|
|
391fb8 |
<<< OK 0x000000004600cb32
|
|
|
391fb8 |
|
|
|
391fb8 |
Remember this is big endian. On big endian machines, it is stored
|
|
|
391fb8 |
directly as 0x46 0x00 0xcb 0x32.
|
|
|
391fb8 |
|
|
|
391fb8 |
On a little endian machine, we have to first swap it, so that it becomes
|
|
|
391fb8 |
0x32cb0046. When written to memory, it becomes 0x46 0x00 0xcb 0x32
|
|
|
391fb8 |
again.
|
|
|
391fb8 |
|
|
|
391fb8 |
Reading byte-by-byte works too, of course:
|
|
|
391fb8 |
|
|
|
391fb8 |
>>> readb 0x9020000
|
|
|
391fb8 |
<<< OK 0x0000000000000038
|
|
|
391fb8 |
>>> readb 0x9020000
|
|
|
391fb8 |
<<< OK 0x00000000000000ec
|
|
|
391fb8 |
|
|
|
391fb8 |
Here only a single byte is read at a time, so they are read in order
|
|
|
391fb8 |
similar to the 1-byte data port that is already in PPC and SPARC
|
|
|
391fb8 |
machines.
|
|
|
391fb8 |
|
|
|
391fb8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
391fb8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
391fb8 |
Message-id: 1419250305-31062-8-git-send-email-pbonzini@redhat.com
|
|
|
391fb8 |
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
391fb8 |
(cherry picked from commit 6c87e3d5967a1d731b5f591a8f0ee6c319c14ca8)
|
|
|
391fb8 |
---
|
|
|
391fb8 |
hw/nvram/fw_cfg.c | 12 +++++++++---
|
|
|
391fb8 |
include/hw/nvram/fw_cfg.h | 2 ++
|
|
|
391fb8 |
2 files changed, 11 insertions(+), 3 deletions(-)
|
|
|
391fb8 |
|
|
|
391fb8 |
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
|
|
|
391fb8 |
index 2950d68..fcdf821 100644
|
|
|
391fb8 |
--- a/hw/nvram/fw_cfg.c
|
|
|
391fb8 |
+++ b/hw/nvram/fw_cfg.c
|
|
|
391fb8 |
@@ -663,14 +663,14 @@ FWCfgState *fw_cfg_init_io(uint32_t iobase)
|
|
|
391fb8 |
return FW_CFG(dev);
|
|
|
391fb8 |
}
|
|
|
391fb8 |
|
|
|
391fb8 |
-FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr)
|
|
|
391fb8 |
+FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, hwaddr data_addr,
|
|
|
391fb8 |
+ uint32_t data_width)
|
|
|
391fb8 |
{
|
|
|
391fb8 |
DeviceState *dev;
|
|
|
391fb8 |
SysBusDevice *sbd;
|
|
|
391fb8 |
|
|
|
391fb8 |
dev = qdev_create(NULL, TYPE_FW_CFG_MEM);
|
|
|
391fb8 |
- qdev_prop_set_uint32(dev, "data_width",
|
|
|
391fb8 |
- fw_cfg_data_mem_ops.valid.max_access_size);
|
|
|
391fb8 |
+ qdev_prop_set_uint32(dev, "data_width", data_width);
|
|
|
391fb8 |
|
|
|
391fb8 |
fw_cfg_init1(dev);
|
|
|
391fb8 |
|
|
|
391fb8 |
@@ -681,6 +681,12 @@ FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr)
|
|
|
391fb8 |
return FW_CFG(dev);
|
|
|
391fb8 |
}
|
|
|
391fb8 |
|
|
|
391fb8 |
+FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr)
|
|
|
391fb8 |
+{
|
|
|
391fb8 |
+ return fw_cfg_init_mem_wide(ctl_addr, data_addr,
|
|
|
391fb8 |
+ fw_cfg_data_mem_ops.valid.max_access_size);
|
|
|
391fb8 |
+}
|
|
|
391fb8 |
+
|
|
|
391fb8 |
|
|
|
391fb8 |
FWCfgState *fw_cfg_find(void)
|
|
|
391fb8 |
{
|
|
|
391fb8 |
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
|
|
|
391fb8 |
index a99586e..6d8a8ac 100644
|
|
|
391fb8 |
--- a/include/hw/nvram/fw_cfg.h
|
|
|
391fb8 |
+++ b/include/hw/nvram/fw_cfg.h
|
|
|
391fb8 |
@@ -80,6 +80,8 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,
|
|
|
391fb8 |
size_t len);
|
|
|
391fb8 |
FWCfgState *fw_cfg_init_io(uint32_t iobase);
|
|
|
391fb8 |
FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr);
|
|
|
391fb8 |
+FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, hwaddr data_addr,
|
|
|
391fb8 |
+ uint32_t data_width);
|
|
|
391fb8 |
|
|
|
391fb8 |
FWCfgState *fw_cfg_find(void);
|
|
|
391fb8 |
|
|
|
391fb8 |
--
|
|
|
391fb8 |
2.1.0
|
|
|
391fb8 |
|